Description
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
dict
instead ofOrderedDict
(gh-104683: Argument clinic: usedict
overOrderedDict
#104647) -
Simplify code like this by using the
str.removesuffix
andstr.removeprefix
methods, both new in Python 3.9:
cpython/Tools/clinic/clinic.py
Lines 2572 to 2575 in 06eeee9
(gh-104683: Modernise
clinic.py
usingstr.removeprefix
andstr.removesuffix
#104685) -
Pyupgrade (run using the
--py310-plus
setting) 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
Cc. @erlend-aasland
Linked PRs
- gh-104683: Argument clinic: use
dict
overOrderedDict
#104647 - gh-104683: Modernise
Tools/clinic/
using pyupgrade #104684 - gh-104683: Modernise
clinic.py
usingstr.removeprefix
andstr.removesuffix
#104685 - gh-104683: clinic.py: Modernise
parse_converter()
using pattern-matching #104696 - gh-104683:
clinic.py
: Improve coverage for theparse_converter
method #104729 - [3.11] gh-104683:
clinic.py
: Improve coverage for theparse_converter
method (#104729) #104730 - gh-104683: Modernise Argument Clinic parameter state machine #106362
- gh-104683: Rename clinic.test => clinic.test.c #106443
- [3.12] gh-104683: Rename Lib/test/clinic.test as Lib/test/clinic.test.c (GH-106443) #106444
- [3.11] gh-104683: Rename Lib/test/clinic.test as Lib/test/clinic.test.c (GH-106443) #106445
- gh-104683: clinic.py: refactor four simple classes as dataclasses #106476
- gh-104683: clinic.py: refactor
Parameter
andFunction
as dataclasses #106477 - gh-104683: clinic.py: Don't needlessly reimplement
contextlib.redirect_stdout
#106478 - gh-104683: Argument clinic: Minor readability improvements for
Destination.__init__
#106652 - gh-104683: Argument clinic: modernise
cpp.Monitor
#106698 - gh-104683: Argument clinic: use an enum to describe the different kinds of functions #106721
- gh-104683: Argument Clinic: Modernise parse_special_symbol() #106837
- gh-104683: Argument Clinic: Make most arguments to
Class
andFunction
required #107289 - gh-104683: Argument clinic: cleanup
state_modulename_name()
#107340 - gh-104683: Argument clinic: pass
clinic
as a parameter where possible #107435 - gh-104683: Argument clinic: Make the
filename
parameter toClinic
required #107439 - gh-104683: Argument clinic: remove the
LandMine
class #107541 - gh-104683: Argument clinic: cleanup
DLSParser
state_foo
methods #107543 - gh-104683: Argument Clinic: Refactor and simplify 'add docstring' states #107550
- gh-104683: Rework Argument Clinic error handling #107551
- gh-104683: Make Argument Clinic template strings class level members #107556
- gh-104683: Argument Clinic: refactor format_docstring() #107623
- gh-104683: Argument clinic: remove some unnecessary uses of
self.next()
in the DSLParser #107635 - gh-104683: Argument Clinic: Use CConverter.length_name where possible #107638
- gh-104683: Improve consistency and test coverage of argument-clinic
__repr__
functions #107667 - gh-104683: Add --exclude option to Argument Clinic CLI #107770
- gh-104683: Remove unused variables from
Tools/clinic
and tests forTools/clinic
#107771 - gh-104683: Argument Clinic: Params now render their own docstrings #107790
- gh-104683: Argument clinic: make
format_docstring()
a method onFunction
objects #107840 - gh-104683: Argument Clinic: Extract parse_function_names() helper #107964
- gh-104683: Argument Clinic: Remove unreachable code from _module_and_class() #108092
- gh-104683: Argument Clinic: Refactor the module and class resolver #108552