Skip to content

Handle when the 'ancestors' attribute is not present in an object #5647

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
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 CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -595,3 +595,6 @@ contributors:
* Eero Vuojolahti: contributor

* Kian-Meng, Ang: contributor

* Julia Eskew (doctoryes): contributor
- Fixed issue 5646, handle when the 'ancestors' attribute is not present in an object
9 changes: 9 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,15 @@ Release date: TBA
(Ie. not necessarily at the end)


What's New in Pylint 2.12.3?
============================
Release date:

* Fixed handling of missing 'ancestors' object attribute.

Closes #5646


Comment on lines +194 to +202
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have a bug fix branch for 2.12 currently so we do not back-port those fix. This is something that we'd need to put into place after we release 2.13 but right now this is going to be in 2.13.

Suggested change
What's New in Pylint 2.12.3?
============================
Release date:
* Fixed handling of missing 'ancestors' object attribute.
Closes #5646
* Fixed handling of missing 'ancestors' object attribute.
Closes #5646

What's New in Pylint 2.12.2?
============================
Release date: 2021-11-25
Expand Down
4 changes: 4 additions & 0 deletions doc/whatsnew/2.12.rst
Original file line number Diff line number Diff line change
Expand Up @@ -255,3 +255,7 @@ Other Changes
or ``not in`` checks

Closes #5323

* Fixed handling of missing 'ancestors' object attribute.

Closes #5646
2 changes: 1 addition & 1 deletion pylint/checkers/refactoring/implicit_booleaness_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,5 +213,5 @@ def base_classes_of_node(instance: nodes.ClassDef) -> List[str]:
"""Return all the classes names that a ClassDef inherit from including 'object'."""
try:
return [instance.name] + [x.name for x in instance.ancestors()]
except TypeError:
except (TypeError, AttributeError):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice straightforward fix, I like it :)

return [instance.name]