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

AttributeError: 'NoneType' object has no attribute 'scope' in variables checker #10105

Open
correctmost opened this issue Dec 3, 2024 · 0 comments
Labels
Crash 💥 A bug that makes pylint crash Needs PR This issue is accepted, sufficiently specified and now needs an implementation

Comments

@correctmost
Copy link
Contributor

correctmost commented Dec 3, 2024

Bug description

Pylint crashes on this fuzzed code from pysource-codegen:

@d
class a:
    d: int

import d

Configuration

Command used

pylint crash.py

Pylint output

Exception on node <Name.d l.1 at 0x77162afcce90> in file 'crash.py'
Traceback (most recent call last):
  File "pylint/pylint/utils/ast_walker.py", line 87, in walk
    callback(astroid)
  File "pylint/pylint/checkers/variables.py", line 1651, in visit_name
    self._undefined_and_used_before_checker(node, stmt)
  File "pylint/pylint/checkers/variables.py", line 1694, in _undefined_and_used_before_checker
    action, nodes_to_consume = self._check_consumer(
                               ^^^^^^^^^^^^^^^^^^^^^
  File "pylint/pylint/checkers/variables.py", line 1942, in _check_consumer
    elif not self._is_builtin(node.name) and self._is_only_type_assignment(
                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "pylint/pylint/checkers/variables.py", line 2415, in _is_only_type_assignment
    parent_scope = parent.scope()
                   ^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'scope'

Expected behavior

No crash

Pylint version

pylint: 55098c7
astroid: cae4388d75
Python 3.12.7

OS / Environment

Arch Linux

Additional dependencies

@correctmost correctmost added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Dec 3, 2024
@Pierre-Sassoulas Pierre-Sassoulas 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 Dec 5, 2024
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 PR This issue is accepted, sufficiently specified and now needs an implementation
Projects
None yet
Development

No branches or pull requests

2 participants