Title: gh-104683: Argument clinic: remove some unnecessary uses of `self.next()` in the DSLParser by AlexWaygood · Pull Request #107635 · python/cpython · GitHub
Open Graph Title: gh-104683: Argument clinic: remove some unnecessary uses of `self.next()` in the DSLParser by AlexWaygood · Pull Request #107635 · python/cpython
X Title: gh-104683: Argument clinic: remove some unnecessary uses of `self.next()` in the DSLParser by AlexWaygood · Pull Request #107635 · python/cpython
Description: Many state_foo methods on the DSLParser class in clinic.py are called only indirectly via the next() method: cpython/Tools/clinic/clinic.py Lines 4645 to 4652 in 407d7fd def next( self, state: StateKeeper, line: str | None = None ) -> None: self.state = state if line is not None: self.state(line) The reason for this is that the DSLParser parses argument-clinic input a line at a time; but state often persists across lines. (Example: a docstring can span multiple lines; by saving the "state" at the end of one line, the DSLParser is able to resume parsing with the same state when it begins parsing the next line, and therefore knows that it's in the middle of a docstring.) However, there are two state_foo methods on the DSLParser class that are arguably badly named, and shouldn't be called via self.next(), even though they both currently are: state_modulename_name state_parameter_docstring_start Both of these are examples of states that are impossible to span multiple lines. A modulename declaration cannot span multiple lines; nor can the start of a parameter docstring. As such, calling these methods via self.next() is needless indirection, and can be removed. It is provable that both of these states cannot span multiple lines, due to the fact that neither state_modulename_name nor state_parameter_docstring_start ever exit early before setting self.state to something new (by calling self.next). Issue: gh-104683
Open Graph Description: Many state_foo methods on the DSLParser class in clinic.py are called only indirectly via the next() method: cpython/Tools/clinic/clinic.py Lines 4645 to 4652 ...
X Description: Many state_foo methods on the DSLParser class in clinic.py are called only indirectly via the next() method: cpython/Tools/clinic/clinic.py Lines 4645 to 4652 ...
Opengraph URL: https://github.com/python/cpython/pull/107635
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:d98e54c2-7770-be9d-c8be-42371efa5f8e |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | D918:1FFDC1:F11EC6:1504916:696A29A1 |
| html-safe-nonce | 695081acbbd693640faceaf35e5f51f953bc0d8d80bc554e8a09914d13bbf1f4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEOTE4OjFGRkRDMTpGMTFFQzY6MTUwNDkxNjo2OTZBMjlBMSIsInZpc2l0b3JfaWQiOiIzMjI1ODA0MTY2NjA0MTM4OTEzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 9c8556610c5be098ad942d6b7c6995b00d70cab0b0b76925947793d32d1d7a29 |
| hovercard-subject-tag | pull_request:1463158859 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/python/cpython/pull/107635/files |
| twitter:image | https://avatars.githubusercontent.com/u/66076021?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/66076021?s=400&v=4 |
| og:image:alt | Many state_foo methods on the DSLParser class in clinic.py are called only indirectly via the next() method: cpython/Tools/clinic/clinic.py Lines 4645 to 4652 ... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | a1022f03e4f0d91ea173e4e5dac892c982e0588c62f1ce56121d755a320a3569 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f472b8e6c7b3fdd5d0354972a3f4c516289bf0be |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width