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

Crash argument of type 'Const' is not iterable #5935

Closed
tjprescott opened this issue Mar 18, 2022 · 1 comment · Fixed by #7153
Closed

Crash argument of type 'Const' is not iterable #5935

tjprescott opened this issue Mar 18, 2022 · 1 comment · Fixed by #7153
Labels
Astroid Related to astroid Crash 💥 A bug that makes pylint crash
Milestone

Comments

@tjprescott
Copy link

tjprescott commented Mar 18, 2022

Bug description

When parsing the following file:

from azure.core import CaseInsensitiveEnumMeta
from enum import Enum
from six import with_metaclass


class PetEnumPy2Metaclass(with_metaclass(CaseInsensitiveEnumMeta, Enum)):
    DOG = "dog"

pylint crashed with a TypeError and with the following stacktrace:

Traceback (most recent call last):
  File "C:\Users\travi\.pyenv\pyenv-win\versions\3.10.2\lib\site-packages\pylint\lint\pylinter.py", line 1034, in _check_files
    self._check_file(get_ast, check_astroid_module, file)
  File "C:\Users\travi\.pyenv\pyenv-win\versions\3.10.2\lib\site-packages\pylint\lint\pylinter.py", line 1069, in _check_file
    check_astroid_module(ast_node)
  File "C:\Users\travi\.pyenv\pyenv-win\versions\3.10.2\lib\site-packages\pylint\lint\pylinter.py", line 1203, in check_astroid_module
    retval = self._check_astroid_module(
  File "C:\Users\travi\.pyenv\pyenv-win\versions\3.10.2\lib\site-packages\pylint\lint\pylinter.py", line 1250, in _check_astroid_module
    walker.walk(node)
  File "C:\Users\travi\.pyenv\pyenv-win\versions\3.10.2\lib\site-packages\pylint\utils\ast_walker.py", line 75, in walk
    self.walk(child)
  File "C:\Users\travi\.pyenv\pyenv-win\versions\3.10.2\lib\site-packages\pylint\utils\ast_walker.py", line 75, in walk
    self.walk(child)
  File "C:\Users\travi\.pyenv\pyenv-win\versions\3.10.2\lib\site-packages\pylint\utils\ast_walker.py", line 75, in walk
    self.walk(child)
  File "C:\Users\travi\.pyenv\pyenv-win\versions\3.10.2\lib\site-packages\pylint\utils\ast_walker.py", line 72, in walk
    callback(astroid)
  File "C:\Users\travi\.pyenv\pyenv-win\versions\3.10.2\lib\site-packages\pylint\checkers\base.py", line 1994, in visit_assignname
    if not list(frame.local_attr_ancestors(node.name)):
  File "C:\Users\travi\.pyenv\pyenv-win\versions\3.10.2\lib\site-packages\astroid\nodes\scoped_nodes\scoped_nodes.py", line 2606, in local_attr_ancestors
    if name in astroid:
TypeError: argument of type 'Const' is not iterable

Configuration

No response

Command used

`python -m pylint ..\apistubgentest`

Pylint output

************* Module apistubgentest.apistubgentest.models._models
F:\repos\azure-sdk-tools\packages\python-packages\apistubgentest\apistubgentest\models\_models.py:38:0: C0301: Line too long (110/100) (line-too-long)
F:\repos\azure-sdk-tools\packages\python-packages\apistubgentest\apistubgentest\models\_models.py:147:0: C0301: Line too long (110/100) (line-too-long)
F:\repos\azure-sdk-tools\packages\python-packages\apistubgentest\apistubgentest\models\_models.py:1:0: C0114: Missing module docstring (missing-module-docstring)
F:\repos\azure-sdk-tools\packages\python-packages\apistubgentest\apistubgentest\models\_models.py:17:0: C0115: Missing class docstring (missing-class-docstring)
F:\repos\azure-sdk-tools\packages\python-packages\apistubgentest\apistubgentest\models\_models.py:18:4: C0203: Metaclass method __getitem__ should have 'cls' as first argument (bad-mcs-method-argument)
F:\repos\azure-sdk-tools\packages\python-packages\apistubgentest\apistubgentest\models\_models.py:29:0: W0613: Unused argument 'kwargs' (unused-argument)
F:\repos\azure-sdk-tools\packages\python-packages\apistubgentest\apistubgentest\models\_models.py:29:4: R0201: Method could be a function (no-self-use)
F:\repos\azure-sdk-tools\packages\python-packages\apistubgentest\apistubgentest\models\_models.py:25:0: R0903: Too few public methods (1/2) (too-few-public-methods)
Exception on node <AssignName.DOG l.48 at 0x1c284a02770> in file 'F:\repos\azure-sdk-tools\packages\python-packages\apistubgentest\apistubgentest\models\_models.py'
Traceback (most recent call last):
  File "C:\Users\travi\.pyenv\pyenv-win\versions\3.10.2\lib\site-packages\pylint\utils\ast_walker.py", line 72, in walk
    callback(astroid)
  File "C:\Users\travi\.pyenv\pyenv-win\versions\3.10.2\lib\site-packages\pylint\checkers\base.py", line 1994, in visit_assignname
    if not list(frame.local_attr_ancestors(node.name)):
  File "C:\Users\travi\.pyenv\pyenv-win\versions\3.10.2\lib\site-packages\astroid\nodes\scoped_nodes\scoped_nodes.py", line 2606, in local_attr_ancestors
    if name in astroid:
TypeError: argument of type 'Const' is not iterable
F:\repos\azure-sdk-tools\packages\python-packages\apistubgentest\apistubgentest\models\_models.py:1:0: F0001: Fatal error while checking '..\apistubgentest\apistubgentest\models\_models.py'. Please open an issue in our bug tracker so we address this. There is a pre-filled template that you can use in 'C:\Users\travi\AppData\Local\pylint\pylint\Cache\pylint-crash-2022-03-18-09.txt'. (fatal)

------------------------------------------------------------------
Your code has been rated at 5.68/10 (previous run: 8.50/10, -2.82)

Expected behavior

Not crash

Pylint version

Python 3.10.2
pylint 2.12.2
astroid 2.9.3

OS / Environment

Windows 10/11. CMD shell.

Additional dependencies

azure-core

six

@tjprescott tjprescott added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Mar 18, 2022
@jacobtylerwalls
Copy link
Member

jacobtylerwalls commented Mar 19, 2022

Thanks @tjprescott, I edited down your report to a MRE. azure-core and six have to be installed. With that, I can reproduce.

It looks like the same issue as pylint-dev/astroid#713, which another user reported was failing once more about a year ago. But rather than re-open an old issue, I think it makes sense to keep a new one open. (The re-report blamed the changes in pylint-dev/astroid#893.)

@jacobtylerwalls jacobtylerwalls added Astroid Related to astroid Crash 💥 A bug that makes pylint crash and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Mar 19, 2022
@jacobtylerwalls jacobtylerwalls added this to the 2.14.0 milestone Mar 26, 2022
@jacobtylerwalls jacobtylerwalls modified the milestones: 2.14.0, 2.15.0 Apr 30, 2022
jacobtylerwalls added a commit to jacobtylerwalls/astroid that referenced this issue Mar 11, 2023
Harden support for using enums as metaclasses.

Fixes the crash in pylint-dev/pylint#5935 by adopting the check
for not-none bases as in ClassDef._inferred_bases without recausing
the false positive reported in pylint-dev/pylint#7506, which requires
correct bases.
jacobtylerwalls added a commit to jacobtylerwalls/astroid that referenced this issue Mar 12, 2023
Harden support for using enums as metaclasses.

Fixes the crash in pylint-dev/pylint#5935 by adopting the check
for not-none bases as in ClassDef._inferred_bases without recausing
the false positive reported in pylint-dev/pylint#7506, which requires
correct bases.
jacobtylerwalls added a commit to pylint-dev/astroid that referenced this issue Mar 26, 2023
…s` (#2049)

Harden support for using enums as metaclasses.

Fixes the crash in pylint-dev/pylint#5935 by adopting the check
for not-none bases as in ClassDef._inferred_bases without recausing
the false positive reported in pylint-dev/pylint#7506, which requires
correct bases.
github-actions bot pushed a commit to pylint-dev/astroid that referenced this issue Mar 26, 2023
…s` (#2049)

Harden support for using enums as metaclasses.

Fixes the crash in pylint-dev/pylint#5935 by adopting the check
for not-none bases as in ClassDef._inferred_bases without recausing
the false positive reported in pylint-dev/pylint#7506, which requires
correct bases.

(cherry picked from commit b5ebf99)
Pierre-Sassoulas pushed a commit to pylint-dev/astroid that referenced this issue Mar 26, 2023
…s` (#2049) (#2067)

Harden support for using enums as metaclasses.

Fixes the crash in pylint-dev/pylint#5935 by adopting the check
for not-none bases as in ClassDef._inferred_bases without recausing
the false positive reported in pylint-dev/pylint#7506, which requires
correct bases.

(cherry picked from commit b5ebf99)

Co-authored-by: Jacob Walls <jacobtylerwalls@gmail.com>
ChristopherManthei pushed a commit to ChristopherManthei/azure-sdk-for-python that referenced this issue Jun 12, 2023
We are hitting pylint-dev/pylint#5935
"TypeError: argument of type 'Const' is not iterable"
As we can't upgrade pylint the only way to fix this is to disable it entirely.
kashifkhan pushed a commit to Azure/azure-sdk-for-python that referenced this issue Jul 6, 2023
…30723)

* RemoteRendering: Fix for pylint error: Use CaseInsensitiveEnumMeta

* Disable pylint

We are hitting pylint-dev/pylint#5935
"TypeError: argument of type 'Const' is not iterable"
As we can't upgrade pylint the only way to fix this is to disable it entirely.

* Fix test resource creation

* Update release date.

* Update release date

* Migrate pylint fix to python 3

Try enabling pylint again

---------

Co-authored-by: Christopher Manthei <chmant@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Astroid Related to astroid Crash 💥 A bug that makes pylint crash
Projects
None yet
2 participants