Skip to content

fix: 🐛 Inspection errors with mypy#265

Merged
remimd merged 3 commits intodevfrom
mypy
Jun 14, 2025
Merged

fix: 🐛 Inspection errors with mypy#265
remimd merged 3 commits intodevfrom
mypy

Conversation

@remimd
Copy link
Copy Markdown
Member

@remimd remimd commented Jun 14, 2025

No description provided.

@remimd remimd requested a review from Copilot June 14, 2025 12:33
@remimd remimd self-assigned this Jun 14, 2025
@remimd remimd merged commit 18c2b3c into dev Jun 14, 2025
5 checks passed
@remimd remimd deleted the mypy branch June 14, 2025 12:35
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 on argument as an empty tuple
  • Refines return type unions for injectable, singleton, scoped, and constant methods
Comments suppressed due to low confidence (1)

injection/init.pyi:313

  • This overload drops the generic T and returns a non‐parameterized _Decorator[type], losing type specificity. Reintroduce the TypeVar so that should_be_injectable preserves the concrete type in its return decorator.
def should_be_injectable(

Comment thread injection/__init__.pyi
cls: _InjectableFactory[T] = ...,
inject: bool = ...,
on: _TypeInfo[T] = ...,
on: _TypeInfo[T],
Copy link

Copilot AI Jun 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
on: _TypeInfo[T],
on: _TypeInfo[T] = ...,

Copilot uses AI. Check for mistakes.
Comment thread injection/__init__.pyi
*,
inject: bool = ...,
on: _TypeInfo[T] = ...,
on: _TypeInfo[T],
Copy link

Copilot AI Jun 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
on: _TypeInfo[T],
on: _TypeInfo[T] = ...,

Copilot uses AI. Check for mistakes.
Comment thread injection/__init__.pyi
*,
inject: bool = ...,
on: _TypeInfo[T] = (),
on: _TypeInfo[T],
Copy link

Copilot AI Jun 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, this overload drops the default for on, making it mandatory. Reintroduce a default value (= ...) to keep the decorator signature consistent and optional.

Suggested change
on: _TypeInfo[T],
on: _TypeInfo[T] = ...,

Copilot uses AI. Check for mistakes.
Comment thread injection/__init__.pyi
/,
*,
on: _TypeInfo[T] = ...,
on: _TypeInfo[T],
Copy link

Copilot AI Jun 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
on: _TypeInfo[T],
on: _TypeInfo[T] = ...,

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants