Skip to content

Commit ebfc647

Browse files
committed
Fix selfcheck
1 parent 350aa53 commit ebfc647

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

mypy/subtypes.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,10 @@ def is_same_type(
287287
)
288288

289289

290-
def is_enum_value_pair(a: ProperType, b: ProperType) -> bool:
290+
def is_enum_value_pair(a: Type, b: Type) -> bool:
291+
a = get_proper_type(a)
292+
b = get_proper_type(b)
293+
291294
if not isinstance(a, LiteralType) or not isinstance(b, LiteralType):
292295
return False
293296
if b.fallback.type.is_enum:
@@ -300,18 +303,16 @@ def is_enum_value_pair(a: ProperType, b: ProperType) -> bool:
300303
return False
301304
assert isinstance(a.value, str)
302305
enum_value = a.fallback.type.get(a.value)
303-
return (
304-
enum_value is not None
305-
and enum_value.type is not None
306-
and isinstance(enum_value.type, Instance)
307-
and (
308-
enum_value.type.last_known_value == b
309-
# TODO: this is too lax and should only be applied for enums defined in stubs,
310-
# but checking that strictly requires access to the checker. This function
311-
# is needed in `is_overlapping_types` and operates on a lower level,
312-
# so doing this properly would be more difficult.
313-
or enum_value.type.type.fullname in ELLIPSIS_TYPE_NAMES
314-
)
306+
if enum_value is None or enum_value.type is None:
307+
return False
308+
proper_value = get_proper_type(enum_value.type)
309+
return isinstance(proper_value, Instance) and (
310+
proper_value.last_known_value == b
311+
# TODO: this is too lax and should only be applied for enums defined in stubs,
312+
# but checking that strictly requires access to the checker. This function
313+
# is needed in `is_overlapping_types` and operates on a lower level,
314+
# so doing this properly would be more difficult.
315+
or proper_value.type.fullname in ELLIPSIS_TYPE_NAMES
315316
)
316317

317318

0 commit comments

Comments
 (0)