DetachHead / basedpyright

pyright fork with various type checking improvements, improved vscode support and pylance features built into the language server
http://docs.basedpyright.com/
Other
601 stars 12 forks source link

Basedpyright marks typing.Optional as deprecated #456

Closed Shtsh closed 4 days ago

Shtsh commented 1 week ago

Basedpyright marks typing.Optional as deprecated

It is not deprecated even though Type | None is a preferable way. This error misguiding and might make person to break compatibility without any proper reason.

Screenshot 2024-06-27 at 17 19 33
DetachHead commented 1 week ago

while i can't find any mention in the docs anywhere that Optional is deprecated, the general consensus seems to be that the new | None syntax is preferred. there's some discussion about it here where one of the typeshed maintainers makes some solid arguments against using it.

also the depreciation comes from upstream pyright, and this is a decision i agree with. but if you prefer to continue using Optional you can disable this error by setting deprecateTypingAliases to false.

that said, i'm not opposed to changing the behaviour if there's a good reason to do so, which i've done before because there are some deprecations i think are really stupid, such as deprecating typing.Callable in favor of collections.abc.Callable even though Callable has literally nothing to do with collections.

DetachHead commented 1 week ago

related: #242

DetachHead commented 4 days ago

closing for the reasons mentioned above, feel free to raise a new issue if you disagree