-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Checking incorrect usage of the keyword 'nonlocal' results in fatal errors. #8735
Comments
Thank you for detecting the bug and opening the issue! |
Add a new checker ``nonlocal-defined-at-module-level`` when a ``nonlocal`` is defined at module-level. Closes pylint-dev#8735
Thanks, I hope these reported bugs are helpful for the development and maintenance of pylint. |
This is a bug that would have been revealed with better type checking. I doubt it is the only place where the code blows past the possibility of a null scope. |
@nickdrozd while on the subject of type checking, do you have a view on whether we should move forward with pylint-dev/astroid#2167 or pylint-dev/astroid#2171? We're thinking of taking one of the two approaches to avoid assigning to methods, which is cluttering a lot of the mypy output now. If it would help for me to write up an astroid issue to summarize the state of the discussion, I'll gladly do it. |
The inference module is pretty gnarly, and it's also responsible for a lot of downstream gnarliness, so I'm in favor of obliterating it along the lines of pylint-dev/astroid#2171. |
* Fix a crash when a ``nonlocal`` is defined at module-level. Closes #8735
* Fix a crash when a ``nonlocal`` is defined at module-level. Closes #8735 (cherry picked from commit 33d3f22) Co-authored-by: Mark Byrne <[email protected]>
If a 'nonlocal' variable are assigned with a variable outside a function, Pylint fails to handle it. See the following example.
example.py:
The expected output:
There is no a fatal error.
The actual output:
Test Environment:
Ubuntu 18.04,
CPython 3.11.3
Pylint: 3.0.0b1
astroid 3.0.0a3
The text was updated successfully, but these errors were encountered: