Skip to content

Commit

Permalink
Reduce the number of executed local imports (#11545)
Browse files Browse the repository at this point in the history
This should speed things up a little, because mypyc
is bad at compiling local imports (mypyc/mypyc#903).
  • Loading branch information
JukkaL committed Nov 13, 2021
1 parent 45a9d84 commit 8f281fb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
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

0 comments on commit 8f281fb

Please sign in to comment.