-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Handle when the 'ancestors' attribute is not present in an object #5647
Conversation
pylint-dev#5646 Handle when the 'ancestors' attribute is not present in an object.
for more information, see https://pre-commit.ci
Pull Request Test Coverage Report for Build 1669502578
π - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for handling this !
Would it be possible to add a regression test in tests/functional/
please ? I'm not sure about what code exactly in opendx is causing the issue but if it's possible to isolate the problem if would be better as the whole file is pretty big.
What's New in Pylint 2.12.3? | ||
============================ | ||
Release date: | ||
|
||
* Fixed handling of missing 'ancestors' object attribute. | ||
|
||
Closes #5646 | ||
|
||
|
There was a problem hiding this comment.
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.
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 |
@@ -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): |
There was a problem hiding this comment.
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 :)
Thanks for the fix @doctoryes, but after some investigation I think we need to handle this differently. I found a reproducible example: class MyClassWithProxy:
@property
def _my_property(cls):
return {}
def func():
xblock = MyClassWithProxy()
assert MyClassWithProxy._my_property == {} Turns out we're not handling |
Hmm, fixing isn't as easy as I thought. I'll probably work on this somewhere next week. class ParentWithProperty:
def _parent_function(cls):
return {}
class MyClassWithProxy(ParentWithProperty):
@property
def _my_property(cls):
return {}
def func():
xblock = MyClassWithProxy()
assert xblock._parent_function == {}
assert xblock._services_requested == {} Both of these comparisons crash right now. I'll try and fix them both at the same time. |
Superseded by #5652. Thanks @doctoryes for the report and initial work. This should be fixed in |
Fix for issue described here: #5646
Handle when the 'ancestors' attribute is not present in an object.
Type of Changes
Description
Closes #5646