Skip to content

Crash: ClassDef has no attribute is_abstract #7742

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

Closed
tushar-deepsource opened this issue Nov 10, 2022 · 3 comments · Fixed by #7744
Closed

Crash: ClassDef has no attribute is_abstract #7742

tushar-deepsource opened this issue Nov 10, 2022 · 3 comments · Fixed by #7744
Labels
Crash 💥 A bug that makes pylint crash Needs review 🔍 Needs to be reviewed by one or multiple more persons Regression
Milestone

Comments

@tushar-deepsource
Copy link
Contributor

tushar-deepsource commented Nov 10, 2022

Bug description

Code:

class Foo:
    __init__ = 42


class Bar(Foo):
    def __init__(self):
        pass

Command used

pylint asd.py

Pylint output

************* Module asd
asd.py:8:0: C0305: Trailing newlines (trailing-newlines)
asd.py:1:0: C0114: Missing module docstring (missing-module-docstring)
asd.py:1:0: C0115: Missing class docstring (missing-class-docstring)
asd.py:1:0: R0903: Too few public methods (0/2) (too-few-public-methods)
asd.py:5:0: C0115: Missing class docstring (missing-class-docstring)
Exception on node <FunctionDef.__init__ l.6 at 0x102b8b130> in file '/Users/tusharsadhwani/code/marvin-python/asd.py'
Traceback (most recent call last):
  File "/Users/tusharsadhwani/code/marvin-python/venv3/lib/python3.10/site-packages/pylint/utils/ast_walker.py", line 90, in walk
    callback(astroid)
  File "/Users/tusharsadhwani/code/marvin-python/venv3/lib/python3.10/site-packages/pylint/checkers/classes/class_checker.py", line 1169, in visit_functiondef
    self._check_init(node, klass)
  File "/Users/tusharsadhwani/code/marvin-python/venv3/lib/python3.10/site-packages/pylint/checkers/classes/class_checker.py", line 2037, in _check_init
    to_call = _ancestors_to_call(klass_node)
  File "/Users/tusharsadhwani/code/marvin-python/venv3/lib/python3.10/site-packages/pylint/checkers/classes/class_checker.py", line 2236, in _ancestors_to_call
    if init_node.is_abstract():
  File "/Users/tusharsadhwani/code/marvin-python/venv3/lib/python3.10/site-packages/astroid/nodes/node_classes.py", line 2009, in __getattr__
    return super().__getattr__(name)
  File "/Users/tusharsadhwani/code/marvin-python/venv3/lib/python3.10/site-packages/astroid/bases.py", line 134, in __getattr__
    return getattr(self._proxied, name)
AttributeError: 'ClassDef' object has no attribute 'is_abstract'
asd.py:1:0: F0002: asd.py: Fatal error while checking 'asd.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/tusharsadhwani/Library/Caches/pylint/pylint-crash-2022-11-10-16-02-44.txt'. (astroid-error)

------------------------------------------------------------------
Your code has been rated at 0.00/10 (previous run: 0.00/10, +0.00)

Expected behavior

No crash

Pylint version

pylint 2.15.5
astroid 2.12.12
Python 3.10.6 (main, Aug 30 2022, 04:58:14) [Clang 13.1.6 (clang-1316.0.21.2.5)]
@tushar-deepsource tushar-deepsource added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Nov 10, 2022
@mbyrnepr2 mbyrnepr2 added Crash 💥 A bug that makes pylint crash Needs PR This issue is accepted, sufficiently specified and now needs an implementation and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Nov 10, 2022
@clavedeluna
Copy link
Contributor

I can never figure out if these types of issues should be moved to the astroid repo?

@tushar-deepsource
Copy link
Contributor Author

imo, if it shows up in Pylint, it should stay in Pylint.
It should be closed when pylint makes a release with the new astroid version.

@mbyrnepr2
Copy link
Member

Regression in 2.15.0

mbyrnepr2 added a commit to mbyrnepr2/pylint that referenced this issue Nov 10, 2022
…rom a parent class with an ``__init__`` class attribute.

Closes pylint-dev#7742
@mbyrnepr2 mbyrnepr2 added Needs review 🔍 Needs to be reviewed by one or multiple more persons and removed Needs PR This issue is accepted, sufficiently specified and now needs an implementation labels Nov 10, 2022
@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.15.6 milestone Nov 12, 2022
mbyrnepr2 added a commit that referenced this issue Nov 12, 2022
* Fix a crash when a child class with an ``__init__`` method inherits from a parent class with an ``__init__`` class attribute.

* `continue` if not a method.

* Update pylint/checkers/classes/class_checker.py

* Rename fragment

Closes #7742

Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
Co-authored-by: Daniël van Noord <13665637+DanielNoord@users.noreply.github.com>
Pierre-Sassoulas added a commit that referenced this issue Nov 16, 2022
* Fix a crash when a child class with an ``__init__`` method inherits from a parent class with an ``__init__`` class attribute.

* `continue` if not a method.

* Update pylint/checkers/classes/class_checker.py

* Rename fragment

Closes #7742

Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
Co-authored-by: Daniël van Noord <13665637+DanielNoord@users.noreply.github.com>
Pierre-Sassoulas added a commit that referenced this issue Nov 17, 2022
* Fix a crash when a child class with an ``__init__`` method inherits from a parent class with an ``__init__`` class attribute.

* `continue` if not a method.

* Update pylint/checkers/classes/class_checker.py

* Rename fragment

Closes #7742

Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
Co-authored-by: Daniël van Noord <13665637+DanielNoord@users.noreply.github.com>
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 Needs review 🔍 Needs to be reviewed by one or multiple more persons Regression
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants