-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
reportUnreachable
and if sys.version_info
#938
Comments
Duplicate of #8 |
well, kinda, but I also propose a semi-solution here:
|
i haven't looked into it but i think that would require the full solution, because pyright currently doesn't have a way to specify multiple valid python versions |
That's not needed in this case. The current |
from my understanding
i agree that this is pretty annoying in many cases because i'm pretty sure the most common use case for it is to define a lower bound. |
Python typing is for the most part backwards-compatible. And if it's not, e.g. when if sys.version_info >= (3, 12):
from collections.abc import Hashable
else:
# deprecated in 3.12
from typing import Hashable So in this case |
i agree that it should behave like that, but since it currently doesn't, and because i want to maintain backwards compatibility with pyright, i will probably keep the current behavior when specifying |
I like that! But I thought you didn't care about that before? ... or was that only @KotlinIsland 🤔 |
@KotlinIsland and i have different goals with our projects. i think backwards compatibility is important (unfortunately) and i can't expect basedpyright to gain any serious adoption without it |
Environment-dependent conditionals like these shouldn't
reportUnreachable
. When testing this on multiple python versions, then it's impossible topyright: ignore[reportUnreachable]
. So the only options left are to either disable it per-module, or disable it globally. Both are sub-optimal.https://basedpyright.com/?typeCheckingMode=all&code=JYWwDg9gTgLgBAZwJ4ILACgPAGaJQOgDcBTKBYCAOwH1hLsI4A%2BAXjgAoBmAGjgEZOASgBcGOOLgATYrgRgAhiHYAqXmCScB1KgBsk1ANYB3eVADmwxDChw2AIkgRHdwXAC0TK1FHoJfuFDEMACuUJRw6pqc2pR6hibmGMQ6CMQ%2BftKyCkquHnAAclRpcPilGEA
So I think that instead,
reportUnreachable
should be limited to code that's "unreachable on all valid platforms and python versions".The text was updated successfully, but these errors were encountered: