9 questions for “Type Hints”

Found in 1 field. Select a question to see its full answer.

Information Technology

9 questions in 2 technologies

#QuestionTechnologyTopicLevel
1How would you write a decorator that validates a function's arguments against its type hints at RUNTIME, since Python doesn't enforce type hints by default? Python › DecoratorsPythonDecoratorsAdvanced
2How does autowiring work in a service container, and how does it use type hints to automatically resolve a class's dependencies? PHP › Dependency Injection & Service ContainersPHPDependency Injection & Service ContainersIntermediate
3How does typing.NamedTuple differ from collections.namedtuple in terms of syntax and type annotation support? Python › Dataclasses & NamedTuplesPythonDataclasses & NamedTuplesIntermediate
4How does functools.singledispatch let you implement function overloading based on an argument's TYPE? Python › DecoratorsPythonDecoratorsAdvanced
5How would you implement a type-validating descriptor that enforces a specific type constraint, reusable across multiple attributes and classes? Python › Descriptors & PropertiesPythonDescriptors & PropertiesAdvanced
6How do you correctly type-hint a function using *args and **kwargs with modern typing, like ParamSpec for preserving a wrapped function's exact signature? Python › Functions & ScopePythonFunctions & ScopeAdvanced
7How do you preserve a decorated function's original SIGNATURE (parameter names, defaults) for introspection tools, beyond what functools.wraps alone provides? Python › DecoratorsPythonDecoratorsAdvanced
8How do keyword-only arguments (using a bare '*' in the parameter list) force certain parameters to be passed by name only? Python › Functions & ScopePythonFunctions & ScopeAdvanced
9How do positional-only parameters (using a bare '/' in the parameter list, Python 3.8+) restrict how certain parameters can be passed? Python › Functions & ScopePythonFunctions & ScopeAdvanced