10000 gh-108494: Argument clinic: Improve the `parse_file()` API by AlexWaygood · Pull Request #108575 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-108494: Argument clinic: Improve the parse_file() API #108575

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

Merged
merged 6 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Address Victor's review
  • Loading branch information
AlexWaygood committed Aug 28, 2023
commit 88626ce751ff2dd7a66fa80914d5b071614d1ba2
10 changes: 4 additions & 6 deletions Lib/test/test_clinic.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@
import clinic
from clinic import DSLParser

DEFAULT_LIMITED_C_API = False


def _make_clinic(*, filename='clinic_tests'):
clang = clinic.CLanguage(None)
c = clinic.Clinic(clang, filename=filename, limited_capi=DEFAULT_LIMITED_C_API)
c = clinic.Clinic(clang, filename=filename, limited_capi=False)
c.block_parser = clinic.BlockParser('', clang)
return c

Expand Down Expand Up @@ -127,7 +125,7 @@ def test_parse_with_body_prefix(self):
clang.body_prefix = "//"
clang.start_line = "//[{dsl_name} start]"
clang.stop_line = "//[{dsl_name} stop]"
cl = clinic.Clinic(clang, filename="test.c", limited_capi=DEFAULT_LIMITED_C_API)
cl = clinic.Clinic(clang, filename="test.c", limited_capi=False)
raw = dedent("""
//[clinic start]
//module test
Expand Down Expand Up @@ -694,7 +692,7 @@ def expect_parsing_failure(
):
errmsg = re.escape(dedent(expected_error).strip())
with self.assertRaisesRegex(clinic.ClinicError, errmsg):
clinic.parse_file(filename, limited_capi=DEFAULT_LIMITED_C_API)
clinic.parse_file(filename, limited_capi=False)

def test_parse_file_no_extension(self) -> None:
self.expect_parsing_failure(
Expand Down Expand Up @@ -862,7 +860,7 @@ def test_round_trip_2(self):

def _test_clinic(self, input, output):
language = clinic.CLanguage(None)
c = clinic.Clinic(language, filename="file", limited_capi=DEFAULT_LIMITED_C_API)
c = clinic.Clinic(language, filename="file", limited_capi=False)
c.parsers['inert'] = InertParser(c)
c.parsers['copy'] = CopyParser(c)
computed = c.parse(input)
Expand Down
4 changes: 2 additions & 2 deletions Tools/clinic/clinic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2413,8 +2413,8 @@ def __init__(
printer: BlockPrinter | None = None,
*,
filename: str,
limited_capi: bool,
verify: bool = True,
limited_capi: bool
) -> None:
# maps strings to Parser objects.
# (instantiated from the "parsers" global.)
Expand Down Expand Up @@ -2611,9 +2611,9 @@ def __repr__(self) -> str:
def parse_file(
filename: str,
*,
limited_capi: bool,
output: str | None = None,
verify: bool = True,
limited_capi: bool,
) -> None:
if not output:
output = filename
Expand Down
0