-
Notifications
You must be signed in to change notification settings - Fork 767
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
Pylance shows a tuple of excepcions arent valid exception #1216
Comments
Can you please provide a self-contained, minimal piece of code that reproduces the behavior? I'm not able to repro the problem from the screen shot above. Here's what I tried, and it seems to work fine: all_errors = (OSError, EOFError)
def func():
try:
...
except all_errors as e:
... I didn't include |
sure
file app.py
|
ftplib is a standard library module, and the tuple in question is defined here: https://github.com/python/typeshed/blob/b0c6598fbaccf92f15a8bc9c47934fd6276eaf78/stdlib/ftplib.pyi#L25 |
OK, thanks for the additional details. This appears to be a bug in the ftplib.pyi type stub. It defines all_errors = Tuple[Type[Exception], ...] In other words, it's defining Based on the documentation, all_errors: Tuple[Type[Exception], ...] I can submit a PR to the typeshed repo with this fix. |
Wow, I completely missed that when I was looking at the stub. |
wow, so its a bug in the python library itself |
Here's the typeshed PR: python/typeshed#5271 |
@Durgeoble, it's not a bug in the python library, but it is a bug in the typeshed stubs that describe the types used in the python library. |
Thanks to very quick turnaround from the maintainers of typeshed, the PR was already accepted and merged. I've pulled the latest typeshed stubs into the pyright repo, so the fix will be incorporated into an upcoming release of pylance. Thanks again for the bug report. |
This issue has been fixed in version 2021.5.0, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/main/CHANGELOG.md#202150-5-may-2021 |
detected in the import from ftplib module all_errors.
Original code from ftplib.
# All exceptions (hopefully) that may be raised here and that aren't
# (always) programming errors on our side
all_errors = (Error, OSError, EOFError)
The text was updated successfully, but these errors were encountered: