Commit Graph

73 Commits

Author SHA1 Message Date
Victor Stinner ad73674283
gh-107603: Argument Clinic: Only include pycore_gc.h if needed (#108726)
Argument Clinic now only includes pycore_gc.h if PyGC_Head is needed,
and only includes pycore_runtime.h if _Py_ID() is needed.

* Add 'condition' optional argument to Clinic.add_include().
* deprecate_keyword_use() includes pycore_runtime.h when using
  the _PyID() function.
* Fix rendering of includes: comments start at the column 35.
* Mark PC/clinic/_wmimodule.cpp.h and
  "Objects/stringlib/clinic/*.h.h" header files as generated in
  .gitattributes.

Effects:

* 42 header files generated by AC no longer include the internal C
  API, instead of 4 header files before. For example,
  Modules/clinic/_abc.c.h no longer includes the internal C API.
* Fix _testclinic_depr.c.h: it now always includes pycore_runtime.h
  to get _Py_ID().
2023-08-31 23:42:34 +02:00
Adam Turner 0bd2ba553d
GH-107603: Clinic: Pass specific attributes to ``print_block()`` (#108581) 2023-08-28 21:31:45 +00:00
Alex Waygood 242bef459b
gh-108494: Argument clinic: Improve the `parse_file()` API (#108575)
Co-authored-by: Victor Stinner <vstinner@python.org>
2023-08-28 18:25:16 +00:00
Erlend E. Aasland d90973340b
gh-104683: Argument Clinic: Refactor the module and class resolver (#108552) 2023-08-28 14:41:05 +02:00
Victor Stinner 86bc9e35c4
gh-108494: AC supports pos-only args in limited C API (#108498)
AC now checks for "#define Py_LIMITED_API" pattern to use the limited
C API.
2023-08-26 00:39:24 +02:00
Victor Stinner 1dd9510977
gh-108494: Argument Clinic partial supports of Limited C API (#108495)
Argument Clinic now has a partial support of the
Limited API:

* Add --limited option to clinic.c.
* Add '_testclinic_limited' extension which is built with
  the limited C API version 3.13.
* For now, hardcode in clinic.py that "_testclinic_limited.c" targets
  the limited C API.
2023-08-25 23:22:08 +02:00
Victor Stinner 4e5a7284ee
gh-108444: Argument Clinic uses PyLong_AsInt() (#108458)
Argument Clinic now uses the new public PyLong_AsInt(), rather than
the old name _PyLong_AsInt().
2023-08-25 00:51:22 +02:00
Serhiy Storchaka 60942cccb1
gh-95065, gh-107704: Argument Clinic: support multiple '/ [from ...]' and '* [from ...]' markers (GH-108132) 2023-08-21 13:59:58 +00:00
Serhiy Storchaka 2f311437cd
gh-107704: Argument Clinic: add support for deprecating keyword use of parameters (GH-107984)
It is now possible to deprecate passing keyword arguments for
keyword-or-positional parameters with Argument Clinic, using the new
'/ [from X.Y]' syntax.
(To be read as "positional-only from Python version X.Y")

Co-authored-by: Erlend E. Aasland <erlend@python.org>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-08-19 10:13:35 +03:00
Erlend E. Aasland 42429d3b9a
gh-104683: Argument Clinic: Extract parse function name helper (#107964)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-08-16 13:47:15 +00:00
Erlend E. Aasland 57a20b0960
gh-106368: Argument Clinic: Test that keyword params are disallowed in groups (#107985) 2023-08-16 12:39:56 +02:00
Erlend E. Aasland bb456a08a3
gh-106368: Argument Clinic: Add tests for cloned functions with custom C base names (#107977) 2023-08-15 14:45:53 -06:00
Erlend E. Aasland 607f18c894
gh-107972: Argument Clinic: Ensure a C basename is provided after 'as' (#107973)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2023-08-15 14:41:40 +00:00
Erlend E. Aasland e90036c9bd
gh-107880: Argument Clinic: Fix regression in gh-107885 (#107974)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-08-15 14:00:52 +00:00
Erlend E. Aasland 9b75ada6e4
gh-107880: Teach Argument Clinic to clone __init__ and __new__ methods (#107885) 2023-08-13 12:13:11 +02:00
Erlend E. Aasland ee40b3e20d
gh-107883: Argument Clinic: Handle full module/class path in Function.fulldisplayname (#107884)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-08-12 23:46:00 +00:00
Erlend E. Aasland 39ef93edb9
gh-95065: Argument Clinic: Add functional tests of deprecated positionals (#107768)
Move the "deprecated positinal" tests from clinic.test.c to
_testclinic.c. Mock PY_VERSION_HEX in order to prevent generated
compiler warnings/errors to trigger. Put clinic code for deprecated
positionals in Modules/clinic/_testclinic_depr_star.c.h for easy
inspection of the generated code.

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-08-10 07:19:05 +00:00
Erlend E. Aasland 1b3f5f24af
gh-104683: Argument Clinic: Params now render their own docstrings (#107790)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-08-09 12:44:26 +00:00
Alex Waygood 65ce3652fa
gh-104683: Remove unused variables from `Tools/clinic` and tests for `Tools/clinic` (#107771) 2023-08-09 11:24:05 +01:00
Erlend E. Aasland 0be3743f54
gh-104683: Add --exclude option to Argument Clinic CLI (#107770)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-08-08 20:50:54 +00:00
Alex Waygood 7c5153de5a
gh-106368: Argument clinic: add tests for more failure paths (#107731) 2023-08-08 12:12:49 +00:00
Alex Waygood c399b5e1a5
gh-107713: Reduce usage of mocks in `test_clinic.py` (#107714) 2023-08-07 14:26:49 +01:00
Erlend E. Aasland 33cb0b06ef
gh-95065: Add Argument Clinic support for deprecating positional use of parameters (#95151)
It is now possible to deprecate passing parameters positionally with
Argument Clinic, using the new '* [from X.Y]' syntax.
(To be read as "keyword-only from Python version X.Y")

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-08-07 11:28:08 +00:00
Alex Waygood 6996b406bc
gh-104683: Improve consistency and test coverage of argument-clinic `__repr__` functions (#107667) 2023-08-05 21:58:38 +01:00
Alex Waygood 2c25bd82f4
gh-106368: Argument clinic: improve coverage for `self.valid_line()` calls (#107641) 2023-08-04 20:41:04 +01:00
Erlend E. Aasland ac7605ed19
gh-107614: Normalise Argument Clinic error messages (#107615)
- always wrap the offending line, token, or name in quotes
- in most cases, put the entire error message on one line

Added tests for uncovered branches that were touched by this PR.

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-08-04 12:13:10 +00:00
Erlend E. Aasland 0bd784b355
gh-106368: Increase Argument Clinic test coverage (#107611)
Add tests for directives and destinations
2023-08-04 07:48:32 +00:00
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 9e6590b097
gh-106368: Argument clinic tests: improve error message when `expect_success()` fails (#107606) 2023-08-03 21:26:14 +00:00
Erlend E. Aasland a73daf54eb
gh-106368: Increase Argument Clinic test coverage (#107582)
Add tests for DSL parser state machine and docstring formatting
2023-08-03 09:35:26 +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 b9c9a36c2f
gh-106368: Increase test coverage for Argument Clinic (#107514)
As per this commit, we've got approx. ~91% test coverage for clinic.py.
2023-08-02 13:33:10 +00: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 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 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
Erlend E. Aasland 2c5d206b33
gh-106368: Add test for Argument Clinic misbehaving custom converter_init() (#107496) 2023-07-31 11:50:03 +00: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 76c26eaca4
gh-106368: Argument clinic tests: improve failure message when tests in `ClinicExternalTests` fail (#107364) 2023-07-27 23:57:55 +00:00
Alex Waygood c2b1689abc
gh-104683: Argument clinic: cleanup `state_modulename_name()` (#107340) 2023-07-27 22:51:18 +01:00
Erlend E. Aasland 579100f6d7
gh-106368: Increase Argument Clinic CLI test coverage (#107277) 2023-07-26 08:34:14 +02:00
Erlend E. Aasland 83a2837b32
gh-106368: Increase Argument Clinic CLI test coverage (#107156)
Instead of hacking into the Clinic class, use the Argument Clinic tool
to run the ClinicExternalTest test suite.

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-07-24 20:49:16 +02:00
Erlend E. Aasland ee5c01b473
gh-106368: Increase coverage for Argument Clinic output directive (#106979) 2023-07-22 09:32:10 +00: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 8d228cf66f
gh-106368: Increase Argument Clinic test coverage for IndentStack (#106933) 2023-07-21 08:02:39 +02:00
Erlend E. Aasland 22379c60ab
gh-106368: Increase Argument Clinic test coverage for cpp.Monitor (#106833) 2023-07-17 20:55:10 +00:00
Erlend E. Aasland 2d7d1aa4bc
gh-106368: Increase Argument Clinic BlockParser test coverage (#106759) 2023-07-15 11:28:57 +02:00
Erlend E. Aasland ec45c513d3
gh-106368: Increase Argument Clinic test coverage (#106728)
- improve output_parameter() coverage
- improve coverage for Function.kind
2023-07-13 22:18:32 +00: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 a941bd6c53
gh-104683: Rename Lib/test/clinic.test as Lib/test/clinic.test.c (#106443) 2023-07-05 08:33:05 +00:00