File tree 2 files changed +16
-0
lines changed 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -8645,6 +8645,8 @@ def _ambiguous_enum_variants(types: list[Type]) -> set[str]:
8645
8645
result .add ("<other>" )
8646
8646
elif isinstance (t , LiteralType ):
8647
8647
result .update (_ambiguous_enum_variants ([t .fallback ]))
8648
+ elif isinstance (t , NoneType ):
8649
+ pass
8648
8650
else :
8649
8651
result .add ("<other>" )
8650
8652
return result
Original file line number Diff line number Diff line change @@ -2243,6 +2243,20 @@ def f6(x: IE | Any) -> None:
2243
2243
reveal_type(x) # N: Revealed type is "Union[__main__.IE, Any]"
2244
2244
else:
2245
2245
reveal_type(x) # N: Revealed type is "Union[__main__.IE, Any]"
2246
+
2247
+ def f7(x: IE | None) -> None:
2248
+ if x == IE.X:
2249
+ reveal_type(x) # N: Revealed type is "Literal[__main__.IE.X]"
2250
+ else:
2251
+ reveal_type(x) # N: Revealed type is "Union[Literal[__main__.IE.Y], None]"
2252
+
2253
+ def f8(x: IE | None) -> None:
2254
+ if x is None:
2255
+ reveal_type(x) # N: Revealed type is "None"
2256
+ elif x == IE.X:
2257
+ reveal_type(x) # N: Revealed type is "Literal[__main__.IE.X]"
2258
+ else:
2259
+ reveal_type(x) # N: Revealed type is "Literal[__main__.IE.Y]"
2246
2260
[builtins fixtures/primitives.pyi]
2247
2261
2248
2262
[case testNarrowingWithStrEnum]
You can’t perform that action at this time.
0 commit comments