Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/integrations/writing-integrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/providers/test_derived.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions tests/test_exception_pickling.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion tests/test_resolver_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 7 additions & 7 deletions tests/test_types_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -406,15 +406,15 @@ 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
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
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -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]
Loading