Skip to content
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

Reduce the number of executed local imports #11545

Merged
merged 1 commit into from
Nov 13, 2021
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
4 changes: 2 additions & 2 deletions mypy/argmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,10 @@ def expand_actual_type(self,
This is supposed to be called for each formal, in order. Call multiple times per
formal if multiple actuals map to a formal.
"""
from mypy.subtypes import is_subtype

actual_type = get_proper_type(actual_type)
if actual_kind == nodes.ARG_STAR:
if isinstance(actual_type, Instance) and actual_type.args:
from mypy.subtypes import is_subtype
if is_subtype(actual_type, self.context.iterable_type):
return map_instance_to_supertype(
actual_type,
Expand All @@ -195,6 +194,7 @@ def expand_actual_type(self,
else:
return AnyType(TypeOfAny.from_error)
elif actual_kind == nodes.ARG_STAR2:
from mypy.subtypes import is_subtype
if isinstance(actual_type, TypedDictType):
if formal_kind != nodes.ARG_STAR2 and formal_name in actual_type.items:
# Lookup type based on keyword argument name.
Expand Down
4 changes: 2 additions & 2 deletions mypy/typeops.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,6 @@ class B(A): pass
b = B().copy() # type: B

"""
from mypy.infer import infer_type_arguments

if isinstance(method, Overloaded):
return cast(F, Overloaded([bind_self(c, original_type, is_classmethod)
for c in method.items]))
Expand All @@ -230,6 +228,8 @@ class B(A): pass

variables: Sequence[TypeVarLikeType] = []
if func.variables and supported_self_type(self_param_type):
from mypy.infer import infer_type_arguments

if original_type is None:
# TODO: type check method override (see #7861).
original_type = erase_to_bound(self_param_type)
Expand Down