Commit graph

336 commits

Author SHA1 Message Date
Erlend E. Aasland
a443c310ac
gh-107609: Fix duplicate module check in Argument Clinic (#107610)
Also remove duplicate module def from _testcapi.
2023-08-04 07:28:25 +02:00
Alex Waygood
ee78d01a61
gh-104146: Argument clinic: remove unused methods and variables (#107608) 2023-08-04 00:17:17 +00:00
Erlend E. Aasland
1cd479c6d3
gh-104683: Rework Argument Clinic error handling (#107551)
Introduce ClinicError, and use it in fail(). The CLI runs main(),
catches ClinicError, formats the error message, prints to stderr
and exits with an error.

As a side effect, this refactor greatly improves the accuracy of
reported line numbers in case of error.

Also, adapt the test suite to work with ClinicError.

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-08-03 00:00:06 +00:00
Erlend E. Aasland
bcdd307231
gh-104683: Make Argument Clinic template strings class level members (#107556)
The motivation for this change is to clean up the output_templates()
method a little bit, as it accounts for ~10% of the lines of code in
clinic.py; removing some clutter helps readability.
2023-08-02 21:37:36 +02:00
Erlend E. Aasland
9ff7b4af13
gh-107559: Argument Clinic: complain about non-ASCII chars in param docstrings (#107560)
Previously, only function docstrings were checked for non-ASCII characters.
Also, improve the warn() message.

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-08-02 12:40:23 +00:00
Erlend E. Aasland
439466a02b
gh-104146: Remove dead code from Argument Clinic (#107555) 2023-08-02 09:22:17 +00:00
Erlend E. Aasland
b4d8897781
gh-104683: Argument Clinic: Refactor and simplify 'add docstring' states (#107550)
Introduce docstring_append() helper, and use it for both parameter and
function docstrings. Remove docstring fixup from
do_post_block_processing_cleanup(); instead, make sure no fixup is needed.

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-08-01 23:32:27 +00:00
Alex Waygood
818c83cf81
gh-104683: Argument clinic: cleanup DLSParser state_foo methods (#107543) 2023-08-01 21:42:39 +01:00
Alex Waygood
030f6b1e84
gh-104683: Argument clinic: remove the LandMine class (#107541) 2023-08-01 21:10:54 +01:00
Erlend E. Aasland
49f238e78c
gh-107467: Restructure Argument Clinic command-line interface (#107469)
- Use ArgumentParser.error() to handle CLI errors
- Put the entire CLI in main()
- Rework ClinicExternalTest to call main() instead of using subprocesses

Co-authored-by: AlexWaygood <alex.waygood@gmail.com>
2023-08-01 18:24:23 +02:00
Alex Waygood
5113ed7a2b
gh-104683: Argument clinic: pass clinic as a parameter where possible (#107435) 2023-07-29 19:47:42 +01:00
Alex Waygood
6c74b2f669
gh-104683: Argument clinic: Make the filename parameter to Clinic required (#107439) 2023-07-29 19:46:52 +01:00
Alex Waygood
87de2fbb1e
gh-104050: Argument clinic: enable mypy's --warn-return-any setting (#107405) 2023-07-29 13:39:21 +01:00
Alex Waygood
55ed85e49c
gh-104050: Argument clinic: complete type annotations (#107399) 2023-07-28 21:27:21 +01:00
Alex Waygood
ecc05e23a1
gh-106368: Argument clinic: Fix minor bug in state_modulename_name (#107387) 2023-07-28 19:10:45 +01:00
Alex Waygood
c2b1689abc
gh-104683: Argument clinic: cleanup state_modulename_name() (#107340) 2023-07-27 22:51:18 +01:00
Erlend E. Aasland
2ad699002e
Docs: Argument Clinic: Restructure "Basic concepts and usage" (#106981)
Split "Basic concepts and usage" into:

- Reference
  - Terminology
  - CLI reference

- Background
  - Basic concepts

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com>
2023-07-26 22:08:43 +00:00
Alex Waygood
5aa6964a5c
gh-104050: Argument clinic: Annotate str_converter_key() (#107294) 2023-07-26 21:12:18 +01:00
Alex Waygood
f9bcdf2368
gh-104050: Argument clinic: Complete get_destination_buffer annotations (#107293) 2023-07-26 21:11:15 +01:00
Alex Waygood
14d074e1fb
gh-104683: Argument Clinic: Make most arguments to Class and Function required (#107289) 2023-07-26 11:54:03 +01:00
Alex Waygood
c362678dd2
gh-104050: Argument clinic: improve typing around parse_arg() methods (#107288) 2023-07-26 11:51:24 +01:00
Alex Waygood
33838fedf7
gh-104050: Argument clinic: annotate post_parsing() and cleanup() (#107225) 2023-07-25 23:33:03 +01:00
Alex Waygood
ee9010784c
gh-104050: Argument clinic: more misc typing improvements (#107264) 2023-07-25 22:08:52 +01:00
Alex Waygood
d9e34db993
gh-104050: Argument clinic: more misc typing coverage improvements (#107210) 2023-07-25 08:49:07 +00:00
Alex Waygood
dbfe73837d
gh-104050: Argument clinic: improve typing around adding C converters (#107209) 2023-07-25 09:18:19 +01:00
Alex Waygood
4bbf071635
gh-104050: Argument Clinic: Annotate CRenderData.__init__ (#107207)
Argument Clinic: Annotate `CRenderData.__init__`
2023-07-24 21:38:50 +00:00
Alex Waygood
d93fe5afe2
gh-104050: Argument clinic: misc improvements to type annotation coverage (#107206) 2023-07-24 21:23:58 +00:00
Alex Waygood
ac2d85a174
gh-104050: Argument clinic: annotate format_docstring() (#107200) 2023-07-24 20:29:50 +00:00
Alex Waygood
db17529f80
gh-104050: Argument Clinic: annotate main() (#107192) 2023-07-24 19:32:38 +00:00
Erlend E. Aasland
3aeffc0d8f
gh-104050: Argument Clinic: Increase typing coverage (#107074)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-07-22 22:30:42 +00:00
Erlend E. Aasland
c5adf26b18
gh-104050: Argument Clinic: Annotate the BufferSeries class (#106935)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-07-22 12:46:42 +02:00
Erlend E. Aasland
3372bcba98
gh-106970: Fix Argument Clinic 'destination <name> clear' command (#106972)
Add test for the 'destination <name> clear' command,
and the 'destination' directive in general.

Fix two bugs in 'destination <name> clear' command:

1. The text attribute of the allocator is called 'text', not '_text'
2. Return after processing the 'clear' command,
   instead of proceeding directly to the fail().
2023-07-22 09:43:13 +02:00
Erlend E. Aasland
d81b4f8ff8
gh-104050: Argument Clinic: Annotate the IndentStack class (#106934) 2023-07-20 23:19:11 +00:00
Erlend E. Aasland
1d5a625eb0
gh-104050: Argument Clinic: Increase CConverter typing coverage (#106932)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-07-20 22:45:02 +00:00
Erlend E. Aasland
42c6300d4f
gh-104050: Argument Clinic: Annotate CLanguage.render_option_group_parsing() (#106929)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-07-20 21:33:33 +00:00
Erlend E. Aasland
00e52acebd
gh-104683: Argument Clinic: Modernise parse_special_symbol() (#106837)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-07-17 22:37:11 +00:00
Erlend E. Aasland
036bb73656
gh-104050: Improve Argument Clinic type annotation coverage (#106810)
Add various missing annotations in the following classes:
- BlockPrinter
- CConverter
- CLanguage
- FormatCounterFormatter
- Language
- _TextAccumulator

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-07-17 13:47:08 +02:00
Erlend E. Aasland
383dcbebcd
gh-104050: Argument Clinic: Annotate Clinic.parse() (#106760)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-07-17 00:04:10 +00:00
Erlend E. Aasland
bbf6297985
gh-104050: Argument Clinic: Annotate BlockParser (#106750) 2023-07-15 10:11:32 +00:00
Erlend E. Aasland
7c95345e4f
gh-104050: Argument Clinic: Annotate output_templates() (#106732)
Co-authored-by: AlexWaygood <alex.waygood@gmail.com>
2023-07-14 12:20:58 +00:00
Alex Waygood
128a6c1d88
gh-104683: Argument clinic: use an enum to describe the different kinds of functions (#106721)
Argument clinic: use an enum to describe the different kinds of functions
2023-07-13 22:54:05 +00:00
Erlend E. Aasland
2d43beec22
gh-104050: Argument Clinic: Annotate nested function parser_body() in the CLanguage class (#106699) 2023-07-12 22:49:30 +00:00
Alex Waygood
a180e7a0df
gh-104050: Argument clinic: Annotate the Destination class (#106655)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-07-12 22:33:47 +01:00
Alex Waygood
7ce3ea4906
gh-104683: Argument clinic: Minor readability improvements for Destination.__init__ (#106652) 2023-07-11 23:08:28 +00:00
Alex Waygood
d0972c77aa
gh-104050: Argument Clinic: Annotate the Block class (#106519) 2023-07-11 21:21:14 +00:00
Alex Waygood
363f4f99c5
gh-104683: clinic.py: refactor Parameter and Function as dataclasses (#106477) 2023-07-07 13:10:07 +00:00
Alex Waygood
5548097925
gh-104683: clinic.py: refactor four simple classes as dataclasses (#106476) 2023-07-06 22:17:12 +01:00
Alex Waygood
d0c6ba956f
gh-104683: clinic.py: Don't needlessly reimplement contextlib.redirect_stdout (#106478)
clinic.py: Don't needlessly reimplement `contextlib.redirect_stdout`
2023-07-06 14:23:02 +01:00
Erlend E. Aasland
9d1d4f9c73
gh-64595: Fix regression in file write logic in Argument Clinic (#106449)
Revert the two commits that introduced the regressions:

 - gh-104152
 - gh-104507
2023-07-05 13:23:22 +02:00
Erlend E. Aasland
7bb9fa5ae4
gh-104050: Partially annotate Argument Clinic CLanguage class (#106437)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-07-04 23:07:57 +00:00