Skip to content

Back port typing fixes from dishka #364

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
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 requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ mdurl==0.1.2
# via markdown-it-py
msgspec==0.18.4 ; implementation_name != 'pypy'
# via -r requirements/raw/bench.txt
mypy==1.14.0
mypy==1.15.0
# via -r requirements/raw/lint.txt
mypy-extensions==1.0.0
# via mypy
Expand Down
6 changes: 3 additions & 3 deletions src/adaptix/_internal/type_tools/basic_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ def is_named_tuple_class(tp) -> bool:
)


def is_protocol(tp):
def is_protocol(tp: object) -> bool:
if not isinstance(tp, type):
return False

return Protocol in tp.__bases__
return Protocol in tp.__bases__ # type: ignore[comparison-overlap]


def create_union(args: tuple):
Expand All @@ -64,7 +64,7 @@ def is_user_defined_generic(tp: TypeHint) -> bool:
bool(get_type_vars(tp))
and (
is_subclass_soft(strip_alias(tp), Generic)
or isinstance(tp, typing.TypeAliasType) # type: ignore[attr-defined]
or isinstance(tp, typing.TypeAliasType) # type: ignore[attr-defined, unused-ignore]
)
)
else:
Expand Down
3 changes: 2 additions & 1 deletion src/adaptix/_internal/type_tools/generic_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def _get_members_of_parametrized_generic(self, parametrized_generic) -> MembersS

def _unpack_args(self, args):
if HAS_UNPACK and any(strip_alias(arg) == typing.Unpack for arg in args):
return tuple(arg.source for arg in normalize_type(tuple[args]).args)
subscribed = tuple[args] # type: ignore[valid-type]
return tuple(arg.source for arg in normalize_type(subscribed).args)
return args

def _get_type_var_to_actual(self, type_vars, args):
Expand Down
2 changes: 1 addition & 1 deletion src/adaptix/_internal/type_tools/normalize_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ def _norm_callable(self, tp, origin, args):
)

if args[0] is Ellipsis:
call_args = ...
call_args: Any = ...
elif isinstance(args[0], list):
call_args = self._norm_iter(args[0])
if HAS_TV_TUPLE:
Expand Down
Loading