File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -789,7 +789,7 @@ def false_only(t: Type) -> ProperType:
789789 if not ret_type .can_be_false :
790790 return UninhabitedType (line = t .line )
791791 elif isinstance (t , Instance ):
792- if t .type .is_final or t .type .is_enum :
792+ if ( t .type .is_final or t .type .is_enum ) and state . strict_optional :
793793 return UninhabitedType (line = t .line )
794794 elif isinstance (t , LiteralType ) and t .is_enum_literal ():
795795 return UninhabitedType (line = t .line )
Original file line number Diff line number Diff line change @@ -1964,6 +1964,18 @@ if 'x' in d: # E: "None" has no attribute "__iter__" (not iterable)
19641964reveal_type(d) # N: Revealed type is "None"
19651965[builtins fixtures/dict.pyi]
19661966
1967+ [case testNoWrongUnreachableWarningWithNoStrictOptionalAndFinalInstance]
1968+ # flags: --no-strict-optional --warn-unreachable
1969+ from typing import final, Optional
1970+
1971+ @final
1972+ class C: ...
1973+
1974+ x: Optional[C]
1975+ if not x:
1976+ x = C()
1977+ [builtins fixtures/dict.pyi]
1978+
19671979[case testInferFromEmptyListWhenUsingInWithStrictEquality]
19681980# flags: --strict-equality
19691981def f() -> None:
You can’t perform that action at this time.
0 commit comments