diff --git a/docs/integrations/writing-integrations.md b/docs/integrations/writing-integrations.md index c042a98c..03aa5c87 100644 --- a/docs/integrations/writing-integrations.md +++ b/docs/integrations/writing-integrations.md @@ -408,7 +408,7 @@ When you rewrite: - Remove the marked parameters and leave every other parameter in place, so the framework keeps parsing them. - Assign the cleaned signature to `wrapper.__signature__`. `__signature__` is missing from the stubs, - so add `# ty: ignore[unresolved-attribute]`. + so add `# ty: ignore[missing-attribute]`. - Skip `functools.wraps` when the framework unwraps `__wrapped__` to find the signature, as aiogram does; otherwise it reads the original signature and ignores yours. - Add any parameter the wrapper needs to reach the container, if the handler did not declare it. Typer diff --git a/tests/providers/test_derived.py b/tests/providers/test_derived.py index f964eda8..efef029a 100644 --- a/tests/providers/test_derived.py +++ b/tests/providers/test_derived.py @@ -164,7 +164,7 @@ class G(Group): def test_fn_error_is_reraised_unchanged_with_a_note_naming_the_derived_provider() -> None: def broken(settings: Settings) -> str: - return settings.missing # ty: ignore[unresolved-attribute] + return settings.missing # ty: ignore[missing-attribute] class G(Group): settings = providers.Factory(Settings) diff --git a/tests/test_exception_pickling.py b/tests/test_exception_pickling.py index 2fd2ac36..f709f798 100644 --- a/tests/test_exception_pickling.py +++ b/tests/test_exception_pickling.py @@ -379,7 +379,7 @@ def __repr__(self) -> str: def _self_referencing_error() -> exceptions.ContainerClosedError: error = exceptions.ContainerClosedError(container_scope=Scope.APP) - error.backref = error # ty: ignore[unresolved-attribute] + error.backref = error # ty: ignore[missing-attribute] return error @@ -395,12 +395,12 @@ def test_self_reference_is_restored_as_a_self_reference( restored = _within(5, lambda: round_trip(error)) - assert restored.backref is restored # ty: ignore[unresolved-attribute] + assert restored.backref is restored # ty: ignore[missing-attribute] def test_shallow_copy_of_a_self_reference_points_at_the_original() -> None: error = _self_referencing_error() - assert copy.copy(error).backref is error # ty: ignore[unresolved-attribute] + assert copy.copy(error).backref is error # ty: ignore[missing-attribute] @pytest.mark.parametrize("round_trip", ROUND_TRIPS.values(), ids=ROUND_TRIPS.keys()) diff --git a/tests/test_resolver_compiler.py b/tests/test_resolver_compiler.py index 6febd440..49ed93c4 100644 --- a/tests/test_resolver_compiler.py +++ b/tests/test_resolver_compiler.py @@ -287,7 +287,7 @@ def _needs_one_more(*args: object, extra: object) -> _Bag: # noqa: ARG001 inspect.Parameter(f"p{i}", inspect.Parameter.POSITIONAL_OR_KEYWORD, annotation=t) for i, t in enumerate([_P0, _P1, _P2][:arity]) ] - _needs_one_more.__signature__ = inspect.Signature(params, return_annotation=_Bag) # ty: ignore[unresolved-attribute] + _needs_one_more.__signature__ = inspect.Signature(params, return_annotation=_Bag) # ty: ignore[missing-attribute] _needs_one_more.__annotations__ = {f"p{i}": t for i, t in enumerate([_P0, _P1, _P2][:arity])} | {"return": _Bag} group = _arity_group(arity, creator=_needs_one_more) diff --git a/tests/test_types_parser.py b/tests/test_types_parser.py index b37a85a0..a28d6fe5 100644 --- a/tests/test_types_parser.py +++ b/tests/test_types_parser.py @@ -382,7 +382,7 @@ class _LateDep(_Dep): ... class _NewOnlyCreator: def __new__(cls, dep: _Dep) -> typing.Self: instance = super().__new__(cls) - instance.dep = dep # ty: ignore[unresolved-attribute] + instance.dep = dep # ty: ignore[missing-attribute] return instance @@ -406,7 +406,7 @@ class Dependencies(Group): target = providers.Factory(creator) container = Container(groups=[Dependencies]) - assert isinstance(container.resolve(creator).dep, dep_type) # ty: ignore[unresolved-attribute] + assert isinstance(container.resolve(creator).dep, dep_type) # ty: ignore[missing-attribute] def _signature_only(*parameters: inspect.Parameter, return_annotation: object = inspect.Signature.empty) -> typing.Any: # noqa: ANN401 @@ -414,7 +414,7 @@ def creator(**kwargs: object) -> object: return kwargs del creator.__annotations__["kwargs"], creator.__annotations__["return"] - creator.__signature__ = inspect.Signature( # ty: ignore[unresolved-attribute] + creator.__signature__ = inspect.Signature( # ty: ignore[missing-attribute] list(parameters), return_annotation=return_annotation ) return creator @@ -506,7 +506,7 @@ def test_type_hint_wins_over_signature_annotation() -> None: def creator(**kwargs: object) -> _OtherDep: ... # ty: ignore[empty-body] creator.__annotations__ = {"dep": _OtherDep, "return": _OtherDep} - creator.__signature__ = inspect.Signature([_keyword("dep", _Dep)], return_annotation=_Dep) # ty: ignore[unresolved-attribute] + creator.__signature__ = inspect.Signature([_keyword("dep", _Dep)], return_annotation=_Dep) # ty: ignore[missing-attribute] parsed = parse_creator(creator) @@ -733,7 +733,7 @@ class Dependencies(Group): assert Dependencies.repo.bound_type is _Repo assert isinstance(repo.dep, _Dep) - assert repo.__orig_class__ == _Repo[int] # ty: ignore[unresolved-attribute] + assert repo.__orig_class__ == _Repo[int] # ty: ignore[missing-attribute] assert container.resolve_provider(Dependencies.repo) is repo @@ -769,5 +769,5 @@ class Dependencies(Group): container = Container(groups=[Dependencies]) container.validate() - assert container.resolve_provider(Dependencies.ints).__orig_class__ == _Repo[int] # ty: ignore[unresolved-attribute] - assert container.resolve_provider(Dependencies.strs).__orig_class__ == _Repo[str] # ty: ignore[unresolved-attribute] + assert container.resolve_provider(Dependencies.ints).__orig_class__ == _Repo[int] # ty: ignore[missing-attribute] + assert container.resolve_provider(Dependencies.strs).__orig_class__ == _Repo[str] # ty: ignore[missing-attribute]