Skip to content

Commit 2bdcab4

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 5eb85ad commit 2bdcab4

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
@@ -475,7 +479,8 @@ def is_ignored(path: str):
475479

476480
for source_path in source_paths:
477481
if os.path.isfile(source_path):
478-
check_file(source_path)
482+
if override or not is_ignored(source_path):
483+
check_file(source_path)
479484
else:
480485
for subdir, _, files in os.walk(source_path):
481486
if is_ignored(subdir):
@@ -534,7 +539,20 @@ def is_ignored(path: str):
534539
parser.add_argument(
535540
"--excluded-file-paths",
536541
default="asv_bench/env",
537-
help="Comma separated file paths to exclude.",
542+
help=(
543+
"Comma separated file paths to exclude. If an individual file is "
544+
"explicitly passed in `paths`, it overrides this setting, unless the "
545+
"--no-override flag is used."
546+
),
547+
)
548+
parser.add_argument(
549+
"--no-override",
550+
dest="override",
551+
action="store_false",
552+
help=(
553+
"Don't allow individual files explicitly mentioned in `pahts` to override "
554+
"the excluded file paths (see --excluded-file-paths)."
555+
),
538556
)
539557
parser.add_argument(
540558
"-v",
@@ -552,6 +570,7 @@ def is_ignored(path: str):
552570
output_format=args.format,
553571
file_extensions_to_check=args.included_file_extensions,
554572
excluded_file_paths=args.excluded_file_paths,
573+
override=args.override,
555574
verbose=args.verbose,
556575
)
557576
)

0 commit comments

Comments
 (0)