Skip to content

[fix] Fix a crash for class decorators mistaken for class attributes #10362

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/whatsnew/fragments/10105.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fixed a crash when importing a class decorator that did not exist with the same name than a class attribute after the class definition.

Closes #10105
2 changes: 1 addition & 1 deletion pylint/checkers/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -2445,7 +2445,7 @@ def _is_only_type_assignment(
node_frame = node.frame()

parent = node
while parent is not defstmt_frame.parent:
while parent not in {defstmt_frame.parent, None}:
parent_scope = parent.scope()

# Find out if any nonlocals receive values in nested functions
Expand Down
9 changes: 9 additions & 0 deletions tests/functional/r/regression_02/regression_10105.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# pylint: disable=too-few-public-methods,missing-docstring,used-before-assignment,import-error,unused-import
# pylint: disable=wrong-import-position


@decorator
class DecoratedClass:
decorator: int

import decorator
Loading