Fix __doc__ on unbound method#2958
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2958 +/- ##
==========================================
- Coverage 93.31% 93.30% -0.01%
==========================================
Files 92 92
Lines 11292 11295 +3
==========================================
+ Hits 10537 10539 +2
- Misses 755 756 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
Hey @DanielNoord! I was just working on this same issue. I should've commented that but no worries 😄 .
class A:
def test(self): pass
A.test.__eq__ # Returns Unknown, not Uninferable
class Base:
def method(self):
return super().__doc__
Base().method() # Returns Unknown, not UninferableI think the fix can be adding Unknown filtering to |
|
@emmanuel-ferdman Let's open a different PR for your fix! It is indeed valuable, but I think we can apply both as they have somewhat different (but good) effects 😄 |
|
@jacobtylerwalls Unrelated to this PR, but this action failed: https://github.com/pylint-dev/astroid/actions/runs/22041554054 |
Type of Changes
Description
Fixes the issue as described in #2847
The reproducer for the crash is:
That could be fixed in
pylint(by not callingpytype()onNodeNGsubclasses that don't have it), but that seems unnecessary.Instead we can (I hope/think) better represent the actual object model by letting
UnboundMethodModelinherit fromFunctionModel. That feels like it would make sense? The test doesn't pass without this fix.We could add
attr___doc__onUnboundMethodModelbut for me this feels like it better fits at least my own mental model of Python objects 😅