From 2ad4f481ad1ffaf626a435a4d1c84ab85029e773 Mon Sep 17 00:00:00 2001 From: hauntsaninja Date: Fri, 19 Jul 2024 18:33:01 -0700 Subject: [PATCH] Fix types.GenericAlias lookup crash Fixes #17542 --- mypy/checkexpr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypy/checkexpr.py b/mypy/checkexpr.py index 3532e18b93b2..2e8e6e2db9d5 100644 --- a/mypy/checkexpr.py +++ b/mypy/checkexpr.py @@ -4341,7 +4341,7 @@ def visit_index_with_type( elif isinstance(left_type, FunctionLike) and left_type.is_type_obj(): if left_type.type_object().is_enum: return self.visit_enum_index_expr(left_type.type_object(), e.index, e) - elif left_type.type_object().type_vars: + elif left_type.type_object().type_vars and self.chk.options.python_version >= (3, 9): return self.named_type("types.GenericAlias") elif ( left_type.type_object().fullname == "builtins.type"