Comments (1)
This is intended behavior. According to the typeshed stubs, NotImplemented
is an instance of the class _NotImplementedType
which is a special class that derives from Any
. In general, classes that drive from Any
must be considered compatible with all other classes unless those classes are final
. The NoneType
class is final, so it cannot possibly be compatible with _NotImplementedType
. In practice, it's problematic to apply this rule to all final
classes, but it is important for a variety of other reasons for the rule to apply to None
in particular. A bunch of other common use cases break without this special case.
FWIW, mypy also applies this special case, and its behavior matches pyright's for the code in your example.
from pyright.
Related Issues (20)
- StrEnum `value` property type regression HOT 2
- `def __init__(self: Self)` causes `reportInvalidTypeVarUse` HOT 1
- reportOverlappingOverload false positive: variadic tuple unpacking HOT 2
- Generic types are reused / only bound once HOT 3
- Introduce `reportUnnecessaryTypeIs` rule HOT 3
- Support different type for class variable and instance variable HOT 3
- Different inferred type `t = tuple(); list(t)` and `list(tuple())` HOT 1
- Type hinting for tuples HOT 4
- `str` is considered incompatible with `Annotated[str]` HOT 1
- `__doc__` inside class body has type `str | None` even though doc-string is defined HOT 1
- `reportIncompatibleMethodOverride` false positive on extra overloads in subclass HOT 1
- Overloaded decorators break type inference for self-referential methods HOT 3
- Changed TypeIs behavior in 1.1.361 to 1.1.364 HOT 2
- Feature Request: Insert all arguments of a function HOT 1
- TypeVar constraint type cannot be generic HOT 1
- False negative when assigning class constants inside __init__ HOT 3
- Argument of `type[A]` cannot be assigned to parameter `cls` of type `type[T@pprint]` HOT 2
- Version 1.1.365 breaks pyright HOT 3
- Regression when loading types for python 3.9 HOT 2
- support multiple config files in the language server HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyright.