-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-108494: AC: change parse_file() API #108504
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -2415,7 +2415,7 @@ def __init__( | |||
*, | ||||
filename: str, | ||||
verify: bool = True, | ||||
limited_capi: bool = False, | ||||
limited_capi: bool = DEFAULT_LIMITED_CAPI, | ||||
) -> None: | ||||
# maps strings to Parser objects. | ||||
# (instantiated from the "parsers" global.) | ||||
|
@@ -2612,11 +2612,10 @@ def __repr__(self) -> str: | |||
def parse_file( | ||||
filename: str, | ||||
*, | ||||
ns: argparse.Namespace, | ||||
output: str | None = None, | ||||
verify: bool = True, | ||||
limited_capi: bool = DEFAULT_LIMITED_CAPI, | ||||
Comment on lines
+2616
to
+2617
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we are using a global cpython/Tools/clinic/clinic.py Line 2393 in 0e8b3fc
Though, I'm actually not sure either There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added a variable for the default to consider changing it tomorrow if AC is shipped as a third party tool. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we should be making decisions now on the basis that we might want to ship AC as a third-party tool in the future. Making AC suitable for use in third-party projects would require quite a few changes across But even if we did want to flip the default tomorrow, I don't think the current structure would make it easy to do so. We'd have to change three places in the code: diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py
index 96ae1e5ad6..5ddaeea855 100755
--- a/Tools/clinic/clinic.py
+++ b/Tools/clinic/clinic.py
@@ -63,7 +63,7 @@
version = '1'
-DEFAULT_LIMITED_CAPI = False
+DEFAULT_LIMITED_CAPI = True
NO_VARARG = "PY_SSIZE_T_MAX"
CLINIC_PREFIX = "__clinic_"
CLINIC_PREFIXED_ARGS = {
@@ -2390,7 +2390,7 @@ def __init__(
*,
filename: str,
verify: bool = True,
- limited_capi: bool = False,
+ limited_capi: bool = True,
) -> None:
# maps strings to Parser objects.
# (instantiated from the "parsers" global.)
@@ -6065,7 +6065,7 @@ def create_cli() -> argparse.ArgumentParser:
cmdline.add_argument("--exclude", type=str, action="append",
help=("a file to exclude in --make mode; "
"can be given multiple times"))
- cmdline.add_argument("--limited", dest="limited_capi", action='store_true',
+ cmdline.add_argument("--no-limited", dest="limited_capi", action='store_false',
help="use the Limited C API")
cmdline.add_argument("filename", metavar="FILE", type=str, nargs="*",
help="the list of files to process") But if we make it so that neither diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py
index 96ae1e5ad6..8866a52f71 100755
--- a/Tools/clinic/clinic.py
+++ b/Tools/clinic/clinic.py
@@ -6065,7 +6065,7 @@ def create_cli() -> argparse.ArgumentParser:
cmdline.add_argument("--exclude", type=str, action="append",
help=("a file to exclude in --make mode; "
"can be given multiple times"))
- cmdline.add_argument("--limited", dest="limited_capi", action='store_true',
+ cmdline.add_argument("--no-limited", dest="limited_capi", action='store_false',
help="use the Limited C API")
cmdline.add_argument("filename", metavar="FILE", type=str, nargs="*",
help="the list of files to process") There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Done. If you prefer, I can just remove DEFAULT_LIMITED_CAPI. Changing the default tomorrow is not a big deal. |
||||
) -> None: | ||||
verify = not ns.force | ||||
limited_capi = ns.limited_capi | ||||
if not output: | ||||
output = filename | ||||
|
||||
|
@@ -6190,7 +6189,8 @@ def run_clinic(parser: argparse.ArgumentParser, ns: argparse.Namespace) -> None: | |||
continue | ||||
if ns.verbose: | ||||
print(path) | ||||
parse_file(path, ns=ns) | ||||
parse_file(path, | ||||
verify=not ns.force, limited_capi=ns.limited_capi) | ||||
return | ||||
|
||||
if not ns.filename: | ||||
|
@@ -6202,7 +6202,8 @@ def run_clinic(parser: argparse.ArgumentParser, ns: argparse.Namespace) -> None: | |||
for filename in ns.filename: | ||||
if ns.verbose: | ||||
print(filename) | ||||
parse_file(filename, output=ns.output, ns=ns) | ||||
parse_file(filename, output=ns.output, | ||||
verify=not ns.force, limited_capi=ns.limited_capi) | ||||
|
||||
|
||||
def main(argv: list[str] | None = None) -> NoReturn: | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer if it specify the version of the limited API, not a simple boolean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now, it only supports Python 3.13. The value can be changed to an int later