Skip to content

Commit bb701b7

Browse files
pythongh-104683: Add --exclude option to Argument Clinic CLI
Explicitly exclude Lib/test/clinic.test.c when running make clinic.
1 parent a9aeb99 commit bb701b7

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

Doc/howto/clinic.rst

+5
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,11 @@ The CLI supports the following options:
188188

189189
The directory tree to walk in :option:`--make` mode.
190190

191+
.. option:: --exclude FILES
192+
193+
Comma-separated list of files to exclude in :option:`--make` mode.
194+
This option has no effect unless :option:`--make` is also given.
195+
191196
.. option:: FILE ...
192197

193198
The list of files to process.

Makefile.pre.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ coverage-report: regen-token regen-frozen
775775
# Run "Argument Clinic" over all source files
776776
.PHONY: clinic
777777
clinic: check-clean-src $(srcdir)/Modules/_blake2/blake2s_impl.c
778-
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/clinic/clinic.py --make --srcdir $(srcdir)
778+
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/clinic/clinic.py --make --exclude Lib/test/clinic.test.c --srcdir $(srcdir)
779779
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/build/generate_global_objects.py
780780

781781
# Build the interpreter
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add ``--exclude`` option to Argument Clinic CLI.

Tools/clinic/clinic.py

+5
Original file line numberDiff line numberDiff line change
@@ -5832,6 +5832,8 @@ def create_cli() -> argparse.ArgumentParser:
58325832
help="walk --srcdir to run over all relevant files")
58335833
cmdline.add_argument("--srcdir", type=str, default=os.curdir,
58345834
help="the directory tree to walk in --make mode")
5835+
cmdline.add_argument("--exclude", type=str,
5836+
help="a list of files to exclude --make mode")
58355837
cmdline.add_argument("filename", metavar="FILE", type=str, nargs="*",
58365838
help="the list of files to process")
58375839
return cmdline
@@ -5903,6 +5905,7 @@ def run_clinic(parser: argparse.ArgumentParser, ns: argparse.Namespace) -> None:
59035905
parser.error("can't use -o or filenames with --make")
59045906
if not ns.srcdir:
59055907
parser.error("--srcdir must not be empty with --make")
5908+
excludes = [os.path.join(ns.srcdir, f) for f in ns.exclude.split(",")]
59065909
for root, dirs, files in os.walk(ns.srcdir):
59075910
for rcs_dir in ('.svn', '.git', '.hg', 'build', 'externals'):
59085911
if rcs_dir in dirs:
@@ -5912,6 +5915,8 @@ def run_clinic(parser: argparse.ArgumentParser, ns: argparse.Namespace) -> None:
59125915
if not filename.endswith(('.c', '.cpp', '.h')):
59135916
continue
59145917
path = os.path.join(root, filename)
5918+
if path in excludes:
5919+
continue
59155920
if ns.verbose:
59165921
print(path)
59175922
parse_file(path, verify=not ns.force)

0 commit comments

Comments
 (0)