# Feature or enhancement Modernise some Python anachronisms in `Tools/clinic/`, to make the code more readable and maintainable. Some things that can be easily done: - [x] Use `dict` instead of `OrderedDict` (#104647) - [x] Simplify code like this by using the `str.removesuffix` and `str.removeprefix` methods, both new in Python 3.9: https://github.com/python/cpython/blob/06eeee97e36aa6bb3d21d7cbc288763ae3a7b21e/Tools/clinic/clinic.py#L2572-L2575 (#104685) - [x] [Pyupgrade](https://github.com/asottile/pyupgrade) (run using the `--py310-plus` setting) also finds various things that can be modernised (#104684) - [ ] Refactor CLanguage.output_templates (see https://github.com/python/cpython/issues/104683#issuecomment-1633266536) - [ ] Put templating in a separate .py file, kind of like Tools/clinic/cpp.py - [x] #107468 - [x] #107467 Cc. @erlend-aasland <!-- gh-linked-prs --> ### Linked PRs * gh-104647 * gh-104684 * gh-104685 * gh-104696 * gh-104729 * gh-104730 * gh-106362 * gh-106443 * gh-106444 * gh-106445 * gh-106476 * gh-106477 * gh-106478 * gh-106652 * gh-106698 * gh-106721 * gh-106837 * gh-107289 * gh-107340 * gh-107435 * gh-107439 * gh-107541 * gh-107543 * gh-107550 * gh-107551 * gh-107556 * gh-107623 * gh-107635 * gh-107638 * gh-107667 * gh-107770 * gh-107771 * gh-107790 * gh-107840 * gh-107964 * gh-108092 * gh-108552 <!-- /gh-linked-prs -->
Feature or enhancement
Modernise some Python anachronisms in
Tools/clinic/, to make the code more readable and maintainable. Some things that can be easily done:Use
dictinstead ofOrderedDict(gh-104683: Argument clinic: usedictoverOrderedDict#104647)Simplify code like this by using the
str.removesuffixandstr.removeprefixmethods, both new in Python 3.9:cpython/Tools/clinic/clinic.py
Lines 2572 to 2575 in 06eeee9
(gh-104683: Modernise
clinic.pyusingstr.removeprefixandstr.removesuffix#104685)Pyupgrade (run using the
--py310-plussetting) also finds various things that can be modernised (gh-104683: ModerniseTools/clinic/using pyupgrade #104684)Refactor CLanguage.output_templates (see Modernise code in
Tools/clinic/#104683 (comment))Put templating in a separate .py file, kind of like Tools/clinic/cpp.py
Rework Argument Clinic error handling #107468
Restructure Argument Clinic CLI #107467
Cc. @erlend-aasland
Linked PRs
dictoverOrderedDict#104647Tools/clinic/using pyupgrade #104684clinic.pyusingstr.removeprefixandstr.removesuffix#104685parse_converter()using pattern-matching #104696clinic.py: Improve coverage for theparse_convertermethod #104729clinic.py: Improve coverage for theparse_convertermethod (#104729) #104730ParameterandFunctionas dataclasses #106477contextlib.redirect_stdout#106478Destination.__init__#106652cpp.Monitor#106698ClassandFunctionrequired #107289state_modulename_name()#107340clinicas a parameter where possible #107435filenameparameter toClinicrequired #107439LandMineclass #107541DLSParserstate_foomethods #107543self.next()in the DSLParser #107635__repr__functions #107667Tools/clinicand tests forTools/clinic#107771format_docstring()a method onFunctionobjects #107840