8000 Reduce the number of executed local imports (#11545) · python/mypy@8f281fb · GitHub
[go: up one dir, main page]

Skip to content

Commit 8f281fb

Browse files
authored
Reduce the number of executed local imports (#11545)
This should speed things up a little, because mypyc is bad at compiling local imports (mypyc/mypyc#903).
1 parent 45a9d84 commit 8f281fb

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

mypy/argmap.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,10 @@ def expand_actual_type(self,
168168
This is supposed to be called for each formal, in order. Call multiple times per
169169
formal if multiple actuals map to a formal.
170170
"""
171-
from mypy.subtypes import is_subtype
172-
173171
actual_type = get_proper_type(actual_type)
174172
if actual_kind == nodes.ARG_STAR:
175173
if isinstance(actual_type, Instance) and actual_type.args:
174+
from mypy.subtypes import is_subtype
176175
if is_subtype(actual_type, self.context.iterable_type):
177176
return map_instance_to_supertype(
178177
actual_type,
@@ -195,6 +194,7 @@ def expand_actual_type(self,
195194
else:
196195
return AnyType(TypeOfAny.from_error)
197196
elif actual_kind == nodes.ARG_STAR2:
197+
from mypy.subtypes import is_subtype
198198
if isinstance(actual_type, TypedDictType):
199199
if formal_kind != nodes.ARG_STAR2 and formal_name in actual_type.items:
200200
# Lookup type based on keyword argument name.

mypy/typeops.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,6 @@ class B(A): pass
209209
b = B().copy() # type: B
210210
211211
"""
212-
from mypy.infer import infer_type_arguments
213-
214212
if isinstance(method, Overloaded):
215213
return cast(F, Overloaded([bind_self(c, original_type, is_classmethod)
216214
for c in method.items]))
@@ -230,6 +228,8 @@ class B(A): pass
230228

231229
variables: Sequence[TypeVarLikeType] = []
232230
if func.variables and supported_self_type(self_param_type):
231+
from mypy.infer import infer_type_arguments
232+
233233
if original_type is None:
234234
# TODO: type check method override (see #7861).
235235
original_type = erase_to_bound(self_param_type)

0 commit comments

Comments
 (0)
0