From bfc2a0f12eabbb88b7387da73254176f60364479 Mon Sep 17 00:00:00 2001 From: Ivan Levkivskyi Date: Tue, 4 Oct 2022 12:05:16 +0100 Subject: [PATCH 1/2] Move an import to avoid cyclic imports --- mypy/maptype.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mypy/maptype.py b/mypy/maptype.py index b0f19376b4a2..caf61647447f 100644 --- a/mypy/maptype.py +++ b/mypy/maptype.py @@ -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 @@ -29,6 +28,8 @@ 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: From cb0ee8f548da186301e94a448751bf67c30c24f9 Mon Sep 17 00:00:00 2001 From: Ivan Levkivskyi Date: Tue, 4 Oct 2022 12:27:59 +0100 Subject: [PATCH 2/2] Fix black --- mypy/maptype.py | 1 + 1 file changed, 1 insertion(+) diff --git a/mypy/maptype.py b/mypy/maptype.py index caf61647447f..cae904469fed 100644 --- a/mypy/maptype.py +++ b/mypy/maptype.py @@ -30,6 +30,7 @@ def map_instance_to_supertype(instance: Instance, superclass: TypeInfo) -> Insta 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: