-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
remove metaclass check for protected access in properties #9966
remove metaclass check for protected access in properties #9966
Conversation
@property | ||
def nargs(self): | ||
return 1 if self._nargs else 2 |
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.
Can you just remove the property
and see if the tests still passes?
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.
If I comment out @property
, it does pass
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #9966 +/- ##
==========================================
- Coverage 95.80% 95.80% -0.01%
==========================================
Files 174 174
Lines 18937 18933 -4
==========================================
- Hits 18143 18139 -4
Misses 794 794
|
This comment has been minimized.
This comment has been minimized.
I believe we should «skip news» on this one. |
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 the PR. Great fan of simplifying the code, not a great fan of removing tests when simplifying the code.
I'd be happy to fix the test instead, but I genuinely don't understand what it's supposed to be doing. It seems to be broken in too many ways to be useful and the intent is unclear as well. I'm not even sure if the behaviour it's testing is correct. |
It's been introduced in #2393, there was a crash when an attribute was uninferable, we need to adapt the test to keep checking for that maybe ? |
I've spent a lot of time trying to find a single path that would lead to an exception described in that issue. I actually kind of began to understand why the test in question is so complicated. Hitting the unhappy path is incredibly involved (and vulnerable to even slight changes in the codebase). So, even when I've removed the fix from that PR, every single test is still passing, including the test in question. So, I think it really makes sense to remove the test altogether. It was testing the quirks of a database from 6 years ago, and it doesn't apply nowadays. |
1. it was incorrect when the property wasn't inside a class and the enclosing class didn't have an explicit metaclass 2. The conjugated test is full with errors and I can't understand the intention. (the errors: `MC` doesn't inherit `type`; `_nargs` isn't defined; `obj` isn't defined, etc). What is the pointed of testing protected access on an undefined variable?..
4f936d3
to
f2591c7
Compare
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.
@Pierre-Sassoulas Okay to merge this?
🤖 According to the primer, this change has no effect on the checked open source code. 🤖🎉 This comment was generated for commit f2591c7 |
it was incorrect when the property wasn't inside a class and the enclosing class didn't have an explicit metaclass
The conjugated test is full with errors and I can't understand the intention. (the errors:
MC
doesn't inherittype
;_nargs
isn't defined;obj
isn't defined, etc). What is the pointed of testing protected access on an undefined variable?..Description
The PR is intentionally extreme (removing the whole test), and I wouldn't be surprised if I missed something and my change is incorrect. I'd be happy to adapt based on the feedback.
The primary reason for this PR is marked as
1.
in the commit description (or above).One situation where this happens is the following. In new astroid "function-call" style properties don't have the enclosing class as the parent. The reason is that the properties themselves are not defined within the class, they are defined within some builtin module. It's just the name that they are assigned to that is defined within the class. So, for example in:
x
is defined withinFoo
, but the property itself isn't. You can read more about it here: pylint-dev/astroid#2553