Conversation
There was a problem hiding this comment.
Pull Request Overview
Fixes mypy inspection errors by updating decorator overload type stubs in the Module class.
- Simplifies overloads by replacing variadic generics with
Callable[..., Any] | type - Adds separate overloads to handle the default
onargument as an empty tuple - Refines return type unions for
injectable,singleton,scoped, andconstantmethods
Comments suppressed due to low confidence (1)
injection/init.pyi:313
- This overload drops the generic
Tand returns a non‐parameterized_Decorator[type], losing type specificity. Reintroduce theTypeVarso thatshould_be_injectablepreserves the concrete type in its return decorator.
def should_be_injectable(
| cls: _InjectableFactory[T] = ..., | ||
| inject: bool = ..., | ||
| on: _TypeInfo[T] = ..., | ||
| on: _TypeInfo[T], |
There was a problem hiding this comment.
This overload makes on a required argument, but previously it had a default (= ...) which allowed optional usage in decorator form. Add a default initializer (= ...) to preserve backwards compatibility and typical decorator usage patterns.
| on: _TypeInfo[T], | |
| on: _TypeInfo[T] = ..., |
| *, | ||
| inject: bool = ..., | ||
| on: _TypeInfo[T] = ..., | ||
| on: _TypeInfo[T], |
There was a problem hiding this comment.
The on parameter here is now required but should remain optional to match previous behavior. Add = ... after its type to allow callers to omit it when using the decorator without explicit target.
| on: _TypeInfo[T], | |
| on: _TypeInfo[T] = ..., |
| *, | ||
| inject: bool = ..., | ||
| on: _TypeInfo[T] = (), | ||
| on: _TypeInfo[T], |
There was a problem hiding this comment.
Similarly, this overload drops the default for on, making it mandatory. Reintroduce a default value (= ...) to keep the decorator signature consistent and optional.
| on: _TypeInfo[T], | |
| on: _TypeInfo[T] = ..., |
| /, | ||
| *, | ||
| on: _TypeInfo[T] = ..., | ||
| on: _TypeInfo[T], |
There was a problem hiding this comment.
The constant overload now forces on to be passed explicitly. It should default to ... so that consumers can omit it when not specifying a target.
| on: _TypeInfo[T], | |
| on: _TypeInfo[T] = ..., |
No description provided.