Skip to content

Commit

Permalink
Move an import to avoid cyclic imports (#13809)
Browse files Browse the repository at this point in the history
This should help people who need to `import mypy.reports` directly, see
#13396 (comment)
  • Loading branch information
ilevkivskyi authored Oct 4, 2022
1 parent dc5c299 commit 78706b6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion mypy/maptype.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations

import mypy.typeops
from mypy.expandtype import expand_type
from mypy.nodes import TypeInfo
from mypy.types import AnyType, Instance, TupleType, Type, TypeOfAny, TypeVarId, has_type_vars
Expand Down Expand Up @@ -29,6 +28,9 @@ def map_instance_to_supertype(instance: Instance, superclass: TypeInfo) -> Insta
env = instance_to_type_environment(instance)
tuple_type = expand_type(instance.type.tuple_type, env)
if isinstance(tuple_type, TupleType):
# Make the import here to avoid cyclic imports.
import mypy.typeops

return mypy.typeops.tuple_fallback(tuple_type)

if not superclass.type_vars:
Expand Down

0 comments on commit 78706b6

Please sign in to comment.