File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3434from mypy .state import state
3535from mypy .types import (
3636 ELLIPSIS_TYPE_NAMES ,
37+ NOT_IMPLEMENTED_TYPE_NAMES ,
3738 AnyType ,
3839 CallableType ,
3940 ExtraAttrs ,
@@ -996,8 +997,10 @@ def is_singleton_identity_type(typ: ProperType) -> bool:
996997 if isinstance (typ , NoneType ):
997998 return True
998999 if isinstance (typ , Instance ):
999- return (typ .type .is_enum and len (typ .type .enum_members ) == 1 ) or (
1000- typ .type .fullname in ELLIPSIS_TYPE_NAMES
1000+ return (
1001+ (typ .type .is_enum and len (typ .type .enum_members ) == 1 )
1002+ or (typ .type .fullname in ELLIPSIS_TYPE_NAMES )
1003+ or (typ .type .fullname in NOT_IMPLEMENTED_TYPE_NAMES )
10011004 )
10021005 if isinstance (typ , LiteralType ):
10031006 return typ .is_enum_literal () or isinstance (typ .value , bool )
Original file line number Diff line number Diff line change @@ -2714,7 +2714,14 @@ reveal_type(t.foo) # N: Revealed type is "__main__.C"
27142714[builtins fixtures/property.pyi]
27152715
27162716[case testNarrowingNotImplemented]
2717+ # flags: --python-version 3.10
27172718from __future__ import annotations
2719+ import types
2720+
2721+ def foo(x: types.NotImplementedType | str):
2722+ if x is not NotImplemented:
2723+ reveal_type(x) # N: Revealed type is "builtins.str"
2724+
27182725from typing_extensions import Self
27192726
27202727class X:
Original file line number Diff line number Diff line change @@ -19,3 +19,5 @@ if sys.version_info >= (3, 10):
1919
2020 class UnionType :
2121 def __or__ (self , x ) -> UnionType : ...
22+
23+ class NotImplementedType : ...
You can’t perform that action at this time.
0 commit comments