Skip to content
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

pylint 2.16 fails on python 3.8.16 #8161

Closed
andy-fox-rozettatech opened this issue Feb 2, 2023 · 7 comments · Fixed by #8163
Closed

pylint 2.16 fails on python 3.8.16 #8161

andy-fox-rozettatech opened this issue Feb 2, 2023 · 7 comments · Fixed by #8163
Labels
Crash 💥 A bug that makes pylint crash
Milestone

Comments

@andy-fox-rozettatech
Copy link

Bug description

pytlint fails itself on python 3.8.
3.9 and above seem OK

packages/pylint/checkers/imports.py", line 179, in _make_tree_defs
node[1] += files
TypeError: 'tuple' object does not support item assignment

Configuration

github actions (or elsewhere)
python 3.8.16

Collecting pylint
  Downloading pylint-2.16.0-py3-none-any.whl (530 kB)

Command used

pylint

Pylint output

Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.8.16/x64/bin/pylint", line 8, in <module>
    sys.exit(run_pylint())
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/pylint/__init__.py", line 36, in run_pylint
    PylintRun(argv or sys.argv[1:])
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/pylint/lint/run.py", line 214, in __init__
    score_value = linter.generate_reports()
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 1149, in generate_reports
    sect = self.make_reports(self.stats, previous_stats)
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/pylint/reporters/reports_handler_mix_in.py", line 76, in make_reports
    r_cb(report_sect, stats, old_stats)
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/pylint/checkers/imports.py", line 981, in _report_external_dependencies
    dep_info = _make_tree_defs(self._external_dependencies_info().items())
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/pylint/checkers/imports.py", line 179, in _make_tree_defs
    node[1] += files
TypeError: 'tuple' object does not support item assignment

Expected behavior

Not to fail ...

Pylint version

pylint 2.16.0

OS / Environment

ubuntu-latest on github actions

but also MacOS 13.2 etc

Additional dependencies

N/A

@andy-fox-rozettatech andy-fox-rozettatech added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Feb 2, 2023
@Pierre-Sassoulas Pierre-Sassoulas added Crash 💥 A bug that makes pylint crash Needs investigation 🔬 A bug or crash where it's not immediately obvious what is happenning and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Feb 2, 2023
@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.16.1 milestone Feb 2, 2023
@Pierre-Sassoulas
Copy link
Member

Thank you for opening the issue. Can you provide any information about the code pylint was run on when it crashed ?

@peanutsven
Copy link

Same here for python 3.7.3,

@DanielNoord
Copy link
Collaborator

Am I dumb or is this really strange?
https://github.com/PyCQA/pylint/blob/5c0084bb1465fcaed2c977266998360b9f2f5661/pylint/checkers/imports.py#L178-L179

How can node[1] be a tuple?

@mschmitzer
Copy link
Contributor

mschmitzer commented Feb 2, 2023

How can node[1] be a tuple?

The problem is node being a tuple. The += is effectively turned into

tmp = node[1]
tmp += files
node[1] = tmp

and assigning the tuple item does not work.
The code was changed here , released in 2.16.

EDIT: Replacing the offending code with node[1].extend(files) would probably fix this.

@DanielNoord
Copy link
Collaborator

Yeah that should fix it. Are you able to provide a patch/PR?

Pierre-Sassoulas added a commit to Pierre-Sassoulas/pylint that referenced this issue Feb 2, 2023
Pierre-Sassoulas added a commit to Pierre-Sassoulas/pylint that referenced this issue Feb 2, 2023
Closes pylint-dev#8161

Co-authored-by: Marc Schmitzer <marc@solute.de>
Pierre-Sassoulas added a commit that referenced this issue Feb 2, 2023
Closes #8161

Co-authored-by: Marc Schmitzer <marc@solute.de>
github-actions bot pushed a commit that referenced this issue Feb 2, 2023
Closes #8161

Co-authored-by: Marc Schmitzer <marc@solute.de>
(cherry picked from commit 4689b19)
@Pierre-Sassoulas Pierre-Sassoulas removed the Needs investigation 🔬 A bug or crash where it's not immediately obvious what is happenning label Feb 2, 2023
@Pierre-Sassoulas
Copy link
Member

If someone has a reproducer this would still be appreciated as this part of the code is not tested properly right now.

Pierre-Sassoulas added a commit that referenced this issue Feb 2, 2023
Closes #8161

Co-authored-by: Marc Schmitzer <marc@solute.de>
(cherry picked from commit 4689b19)

Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
@mschmitzer
Copy link
Contributor

mschmitzer commented Feb 2, 2023

If someone has a reproducer this would still be appreciated as this part of the code is not tested properly right now.

I found one. Interestingly, this does not seem related to the interpreter version, but hashseed dependant:

$ mkvirtualenv test
created virtual environment CPython3.10.6.final.0-64 in 53ms
...
$ pip install pylint
...
Successfully installed astroid-2.14.1 dill-0.3.6 isort-5.12.0 lazy-object-proxy-1.9.0 mccabe-0.7.0 platformdirs-2.6.2 pylint-2.16.0 tomli-2.0.1 tomlkit-0.11.6 typing-extensions-4.4.0 wrapt-1.14.1
$ touch bar.py
$ echo 'import bar' >foo.py
$ PYTHONHASHSEED='3172416510' pylint --rcfile /dev/null -r y foo.py
************* Module foo
foo.py:1:0: C0114: Missing module docstring (missing-module-docstring)
foo.py:1:0: C0104: Disallowed name "foo" (disallowed-name)
foo.py:1:0: W0611: Unused import bar (unused-import)
Traceback (most recent call last):
  File "/home/marc/.venv/test/bin/pylint", line 8, in <module>
    sys.exit(run_pylint())
  File "/home/marc/.venv/test/lib/python3.10/site-packages/pylint/__init__.py", line 36, in run_pylint
    PylintRun(argv or sys.argv[1:])
  File "/home/marc/.venv/test/lib/python3.10/site-packages/pylint/lint/run.py", line 214, in __init__
    score_value = linter.generate_reports()
  File "/home/marc/.venv/test/lib/python3.10/site-packages/pylint/lint/pylinter.py", line 1149, in generate_reports
    sect = self.make_reports(self.stats, previous_stats)
  File "/home/marc/.venv/test/lib/python3.10/site-packages/pylint/reporters/reports_handler_mix_in.py", line 76, in make_reports
    r_cb(report_sect, stats, old_stats)
  File "/home/marc/.venv/test/lib/python3.10/site-packages/pylint/checkers/imports.py", line 981, in _report_external_dependencies
    dep_info = _make_tree_defs(self._external_dependencies_info().items())
  File "/home/marc/.venv/test/lib/python3.10/site-packages/pylint/checkers/imports.py", line 179, in _make_tree_defs
    node[1] += files
TypeError: 'tuple' object does not support item assignment

EDIT: Sorry, I fixed up the example to include the --rcfile /dev/null but didn't adapt the output. Fixed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Crash 💥 A bug that makes pylint crash
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants