-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
pylint crashed with a AstroidError #7821
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
Comments
I can reproduce with: class Command:
def _get_extra_attrs(self, extra_columns):
self.extra_rows_start = 8
for index, column in enumerate(extra_columns, start=self.extra_rows_start):
pass It seems it's due to the false positive fix on enumerate with start, do you want to take a look @clavedeluna ? |
always 😢 to see your recently added code buggy. I'll take a look as soon as I can. |
I can reproduce this with y_start = 2
l = list(range(20))
for y, x in enumerate(l, start=y_start + 1):
pass ************* Module test
test.py:1:0: C0114: Missing module docstring (missing-module-docstring)
test.py:1:0: C0103: Constant name "y_start" doesn't conform to UPPER_CASE naming style (invalid-name)
Exception on node <For l.3 at 0x10de01950> in file '/Users/PanXuehai/test.py'
Traceback (most recent call last):
File "/usr/local/Cellar/pylint/2.15.6/libexec/lib/python3.11/site-packages/pylint/utils/ast_walker.py", line 90, in walk
callback(astroid)
File "/usr/local/Cellar/pylint/2.15.6/libexec/lib/python3.11/site-packages/pylint/checkers/refactoring/refactoring_checker.py", line 682, in visit_for
self._check_unnecessary_list_index_lookup(node)
File "/usr/local/Cellar/pylint/2.15.6/libexec/lib/python3.11/site-packages/pylint/checkers/refactoring/refactoring_checker.py", line 2113, in _check_unnecessary_list_index_lookup
has_start_arg, confidence = self._enumerate_with_start(node)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/pylint/2.15.6/libexec/lib/python3.11/site-packages/pylint/checkers/refactoring/refactoring_checker.py", line 2238, in _enumerate_with_start
start_val, confidence = self._get_start_value(keyword.value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/pylint/2.15.6/libexec/lib/python3.11/site-packages/pylint/checkers/refactoring/refactoring_checker.py", line 2255, in _get_start_value
start_val = node.value
^^^^^^^^^^
AttributeError: 'BinOp' object has no attribute 'value'
test.py:1:0: F0002: test.py: Fatal error while checking 'test.py'. Please open an issue in our bug tracker so we address this. There is a pre-filled template that you can use in '/Users/PanXuehai/Library/Caches/pylint/pylint-crash-2022-11-24-23-24-34.txt'. (astroid-error)
------------------------------------------------------------------
Your code has been rated at 0.00/10 (previous run: 0.00/10, +0.00) |
We're going to fix this in 2.15.7, we're putting a new back-porting mechanism into place right now which temporarily block the release. |
The pylint 2.15.7 was just released. But the fix is not included. |
Yes, sorry it was hard to cherry-pick because it was based on other change that are exclusively on main (and I forgot to upgrade the milestones). The more likely scenario is that it's only going to be available in 2.16.0. |
Bug description
When linting, pylint crashed with a AstroidError and with the following stacktrace:
pylint crashed with a
AstroidError
and with the following stacktrace:with pylint==2.15.5 its ok
Configuration
Command used
prospector --profile-path . --profile .prospector.yaml foo.py
Pylint output
Expected behavior
Pylint does not crash and shows its linting messages (if any) for foo.py
Pylint version
The text was updated successfully, but these errors were encountered: