12
12
13
13
import argparse
14
14
import ast
15
- import os
16
15
import sys
17
16
import token
18
17
import tokenize
19
- from typing import IO , Callable , FrozenSet , Iterable , List , Set , Tuple
18
+ from typing import IO , Callable , Iterable , List , Set , Tuple
20
19
21
20
PRIVATE_IMPORTS_TO_IGNORE : Set [str ] = {
22
21
"_extension_array_shared_docs" ,
@@ -403,8 +402,6 @@ def main(
403
402
function : Callable [[IO [str ]], Iterable [Tuple [int , str ]]],
404
403
source_path : str ,
405
404
output_format : str ,
406
- file_extensions_to_check : str ,
407
- excluded_file_paths : str ,
408
405
) -> bool :
409
406
"""
410
407
Main entry point of the script.
@@ -432,19 +429,9 @@ def main(
432
429
ValueError
433
430
If the `source_path` is not pointing to existing file/directory.
434
431
"""
435
- if not os .path .exists (source_path ):
436
- raise ValueError ("Please enter a valid path, pointing to a file/directory." )
437
-
438
432
is_failed : bool = False
439
- file_path : str = ""
440
-
441
- FILE_EXTENSIONS_TO_CHECK : FrozenSet [str ] = frozenset (
442
- file_extensions_to_check .split ("," )
443
- )
444
- PATHS_TO_IGNORE = frozenset (excluded_file_paths .split ("," ))
445
433
446
- if os .path .isfile (source_path ):
447
- file_path = source_path
434
+ for file_path in source_path :
448
435
with open (file_path ) as file_obj :
449
436
for line_number , msg in function (file_obj ):
450
437
is_failed = True
@@ -454,25 +441,6 @@ def main(
454
441
)
455
442
)
456
443
457
- for subdir , _ , files in os .walk (source_path ):
458
- if any (path in subdir for path in PATHS_TO_IGNORE ):
459
- continue
460
- for file_name in files :
461
- if not any (
462
- file_name .endswith (extension ) for extension in FILE_EXTENSIONS_TO_CHECK
463
- ):
464
- continue
465
-
466
- file_path = os .path .join (subdir , file_name )
467
- with open (file_path ) as file_obj :
468
- for line_number , msg in function (file_obj ):
469
- is_failed = True
470
- print (
471
- output_format .format (
472
- source_path = file_path , line_number = line_number , msg = msg
473
- )
474
- )
475
-
476
444
return is_failed
477
445
478
446
@@ -487,9 +455,7 @@ def main(
487
455
488
456
parser = argparse .ArgumentParser (description = "Unwanted patterns checker." )
489
457
490
- parser .add_argument (
491
- "path" , nargs = "?" , default = "." , help = "Source path of file/directory to check."
492
- )
458
+ parser .add_argument ("paths" , nargs = "*" , help = "Source paths of files to check." )
493
459
parser .add_argument (
494
460
"--format" ,
495
461
"-f" ,
@@ -503,25 +469,13 @@ def main(
503
469
required = True ,
504
470
help = "Validation test case to check." ,
505
471
)
506
- parser .add_argument (
507
- "--included-file-extensions" ,
508
- default = "py,pyx,pxd,pxi" ,
509
- help = "Comma separated file extensions to check." ,
510
- )
511
- parser .add_argument (
512
- "--excluded-file-paths" ,
513
- default = "asv_bench/env" ,
514
- help = "Comma separated file paths to exclude." ,
515
- )
516
472
517
473
args = parser .parse_args ()
518
474
519
475
sys .exit (
520
476
main (
521
477
function = globals ().get (args .validation_type ), # type: ignore
522
- source_path = args .path ,
478
+ source_path = args .paths ,
523
479
output_format = args .format ,
524
- file_extensions_to_check = args .included_file_extensions ,
525
- excluded_file_paths = args .excluded_file_paths ,
526
480
)
527
481
)
0 commit comments