-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
gh-104683: Argument Clinic: Extract parse_function_names() helper #107964
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
gh-104683: Argument Clinic: Extract parse_function_names() helper #107964
Conversation
Reduce duplicate code in state_modulename_name()
This refactor helped me discover a regression of gh-107885; Argument Clinic does not /*[clinic input]
class C "void *" ""
C.meth
a: int
[clinic start generated code]*/
/*[clinic input]
# This should not be allowed!
C.__new__ = C.meth
[clinic start generated code]*/
/*[clinic input]
# Neither should this
@classmethod
C.__init__ = C.meth
[clinic start generated code]*/ We should bake those assertions into the |
Post this, I want to further extract helpers from this stage of the state machine; with this refactor, the remaining code is clearer (simply, since it is fewer lines of code), and it is now obvious we need to do something with the |
Off-topic, but I'm pretty sure this block of code is unreachable FYI: cpython/Tools/clinic/clinic.py Lines 2440 to 2441 in 13c36dc
It's not currently covered by any of our tests. If our type annotations are correct, moreover (and I believe they are), |
There are some corner cases which I think should be fixed:
I suggest we create an issue for this, and retarget this PR as a fix for these issues. |
The knot of code in #107964 (comment) is such a complex conditional (and, it appears, apparently buggy as well) that I think I'd prefer to see a dedicated PR untangling just that bit, and fixing the bug, before we go ahead with a change that factors out the common logic into a helper function. Would that be okay? |
Co-authored-by: Alex Waygood <[email protected]>
Co-authored-by: Alex Waygood <[email protected]>
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.
Thanks!
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.
Oh, one optional other suggestion:
Co-authored-by: Alex Waygood <[email protected]>
Thanks for the review! |
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.
🎉
I'll follow-up with further refactorings in this part of the source code; there's still a lot of duplicated code there. |
Reduce duplicate code in state_modulename_name()
Tools/clinic/
#104683