Skip to content

Commit 3c07fff

Browse files
committed
BLD: add --no-override flag to validate_unwanted_patterns.py
This flag controls whether individual files explicitly passed as arguments should override the --excluded-file-paths rule.
1 parent 12aef80 commit 3c07fff

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

scripts/validate_unwanted_patterns.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@ def main(
407407
output_format: str,
408408
file_extensions_to_check: str,
409409
excluded_file_paths: str,
410+
override: bool,
410411
verbose: int,
411412
) -> bool:
412413
"""
@@ -424,6 +425,9 @@ def main(
424425
Comma separated values of what file extensions to check.
425426
excluded_file_paths : str
426427
Comma separated values of what file paths to exclude during the check.
428+
override:
429+
Whether individual files mentioned in ``source_paths`` should override
430+
``excluded_file_paths``.
427431
verbose : int
428432
Verbosity level (currently only distinguishes between zero and nonzero).
429433
@@ -476,7 +480,8 @@ def is_ignored(path: str):
476480

477481
for source_path in source_paths:
478482
if os.path.isfile(source_path):
479-
check_file(source_path)
483+
if override or not is_ignored(source_path):
484+
check_file(source_path)
480485
else:
481486
for subdir, _, files in os.walk(source_path):
482487
if is_ignored(subdir):
@@ -535,7 +540,20 @@ def is_ignored(path: str):
535540
parser.add_argument(
536541
"--excluded-file-paths",
537542
default="asv_bench/env",
538-
help="Comma separated file paths to exclude.",
543+
help=(
544+
"Comma separated file paths to exclude. If an individual file is "
545+
"explicitly passed in `paths`, it overrides this setting, unless the "
546+
"--no-override flag is used."
547+
),
548+
)
549+
parser.add_argument(
550+
"--no-override",
551+
dest="override",
552+
action="store_false",
553+
help=(
554+
"Don't allow individual files explicitly mentioned in `pahts` to override "
555+
"the excluded file paths (see --excluded-file-paths)."
556+
),
539557
)
540558
parser.add_argument(
541559
"-v",
@@ -553,6 +571,7 @@ def is_ignored(path: str):
553571
output_format=args.format,
554572
file_extensions_to_check=args.included_file_extensions,
555573
excluded_file_paths=args.excluded_file_paths,
574+
override=args.override,
556575
verbose=args.verbose,
557576
)
558577
)

0 commit comments

Comments
 (0)