GeezerVison is showing github.com — Argument Clinic: split out global stateless helpers and constants from clinic.py · Issue #113317 · python/cpython
Argument Clinic: split out global stateless helpers and constants from clinic.py #113317DescriptionFeature or enhancement
clinic.py has a lot of globals in various forms. Getting rid of the globals will make it possible to split out clinic.py in multiple files (#113299). Combined, this will impact readability and maintainability of Argument Clinic in a positive way.
Most globals can be easily dealt with. We can structure them into two groups:
- global constants that are not mutated
- stateless helper functions and classes
It can make sense split out some of these in separate files (for example a libclinic package, as suggested in #113309). For some globals, it makes more sense to embed them into one of the existing classes (for example the global version variable clearly belongs in DSLParser).
Suggesting to start with the following:
- move stateless text accumulator helpers into a
Tools/clinic/libclinic/accumulators.py file
- move stateless text formatting helpers into a
Tools/clinic/libclinic/formatters.py file
- move
version into DSLParser and version helper into a Tools/clinic/libclinic/version.py file
Linked PRs
Activityerlend-aasland commented on Dec 20, 2023 ContributorAuthor More actions Proof-of-concept branch for version: Argument-Clinic/cpython#28 erlend-aasland commented on Dec 20, 2023 ContributorAuthor More actions In #113270 (comment), the need for a refactoring of the docstring generation code arose. If we split out formatting helpers and text accumulators into a libclinic, we can also split out the docstring rendering (format_docstring()). erlend-aasland commented on Dec 21, 2023 ContributorAuthor More actions Follow-up item: when libclinic has been established, we can start partitioning the test suite (Lib/test/test_clinic.py) as well. changed the title [-]Argument Clinic: split out stateless helpers and constants from clinic.py[/-] [+]Argument Clinic: split out global stateless helpers and constants from clinic.py[/+] on Dec 21, 2023erlend-aasland commented on Dec 21, 2023 ContributorAuthor More actions FTR, the global version variable was removed with PR #113341. erlend-aasland commented on Dec 22, 2023 ContributorAuthor More actions Moving the text accumulator APIs (TextAccumulator, _TextAccumulator, text_accumulator, and _text_accumulator) into a libclinic would imply exposing underscore prefixed methods in __all__; that feels weird. Suggested first steps:
I did some experimenting in Argument-Clinic/cpython#30. vstinner commented on Jun 2, 2024 erlend-aasland commented on Jun 2, 2024 ContributorAuthor More actions
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|