docstring-format-checker 1.1.0__tar.gz → 1.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: docstring-format-checker
3
- Version: 1.1.0
3
+ Version: 1.2.0
4
4
  Summary: A CLI tool to check and validate Python docstring formatting and completeness
5
5
  Author: Chris Mahoney
6
6
  Author-email: Chris Mahoney <docstring-format-checker@data-science-extensions.com>
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "docstring-format-checker"
3
- version = "1.1.0"
3
+ version = "1.2.0"
4
4
  description = "A CLI tool to check and validate Python docstring formatting and completeness"
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -216,7 +216,9 @@ def _show_usage_examples_callback() -> None:
216
216
  Execute the below commands in any terminal after installing the package.
217
217
 
218
218
  {_blue("dfc myfile.py")} {_green("# Check a single Python file (list output)")}
219
+ {_blue("dfc myfile.py other_file.py")} {_green("# Check multiple Python files")}
219
220
  {_blue("dfc src/")} {_green("# Check all Python files in src/ directory")}
221
+ {_blue("dfc -x src/app/__init__.py src/")} {_green("# Check all Python files in src/ directory, excluding one init file")}
220
222
  {_blue("dfc --output=table myfile.py")} {_green("# Check with table output format")}
221
223
  {_blue("dfc -o list myfile.py")} {_green("# Check with list output format (default)")}
222
224
  {_blue("dfc --check myfile.py")} {_green("# Check and exit with error if issues found")}
@@ -489,7 +491,7 @@ def _display_results(results: dict[str, list[DocstringError]], quiet: bool, outp
489
491
 
490
492
  # This will be the default behavior when no command is specified
491
493
  def check_docstrings(
492
- path: str,
494
+ paths: list[str],
493
495
  config: Optional[str] = None,
494
496
  exclude: Optional[list[str]] = None,
495
497
  quiet: bool = False,
@@ -501,8 +503,8 @@ def check_docstrings(
501
503
  Core logic for checking docstrings.
502
504
 
503
505
  Params:
504
- path (str):
505
- The path to the file or directory to check.
506
+ paths (list[str]):
507
+ The path(s) to the file(s) or directory(ies) to check.
506
508
  config (Optional[str]):
507
509
  The path to the configuration file.
508
510
  Default: `None`.
@@ -524,14 +526,20 @@ def check_docstrings(
524
526
  Nothing is returned.
525
527
  """
526
528
 
527
- target_path = Path(path)
528
-
529
- # Validate target path
530
- if not target_path.exists():
531
- console.print(_red(f"Error: Path does not exist: '{path}'"))
529
+ # Validate all target paths
530
+ path_objs: list[Path] = [Path(path) for path in paths]
531
+ target_paths: list[Path] = [p for p in path_objs if p.exists()]
532
+ invalid_paths: list[Path] = [p for p in path_objs if not p.exists()]
533
+
534
+ if len(invalid_paths) > 0:
535
+ console.print(
536
+ _red(f"[bold]Error: Paths do not exist:[/bold]"),
537
+ NEW_LINE,
538
+ NEW_LINE.join([f"- '{invalid_path}'" for invalid_path in invalid_paths]),
539
+ )
532
540
  raise Exit(1)
533
541
 
534
- # Load configuration
542
+ # Load configuration (use first path for config discovery if no config specified)
535
543
  try:
536
544
  if config:
537
545
  config_path = Path(config)
@@ -540,8 +548,9 @@ def check_docstrings(
540
548
  raise Exit(1)
541
549
  config_obj = load_config(config_path)
542
550
  else:
543
- # Try to find config file automatically
544
- found_config: Optional[Path] = find_config_file(target_path if target_path.is_dir() else target_path.parent)
551
+ # Try to find config file automatically using the first path
552
+ first_path: Path = target_paths[0]
553
+ found_config: Optional[Path] = find_config_file(first_path if first_path.is_dir() else first_path.parent)
545
554
  if found_config:
546
555
  config_obj: Config = load_config(found_config)
547
556
  else:
@@ -554,19 +563,27 @@ def check_docstrings(
554
563
  # Initialize checker
555
564
  checker = DocstringChecker(config_obj)
556
565
 
557
- # Check files
566
+ # Check all paths and collect results
567
+ all_results: dict[str, list[DocstringError]] = {}
568
+
558
569
  try:
559
- if target_path.is_file():
560
- errors: list[DocstringError] = checker.check_file(target_path)
561
- results: dict[str, list[DocstringError]] = {str(target_path): errors} if errors else {}
562
- else:
563
- results: dict[str, list[DocstringError]] = checker.check_directory(target_path, exclude_patterns=exclude)
570
+ for target_path in target_paths:
571
+ if target_path.is_file():
572
+ errors: list[DocstringError] = checker.check_file(target_path)
573
+ if errors:
574
+ all_results[str(target_path)] = errors
575
+ else:
576
+ directory_results: dict[str, list[DocstringError]] = checker.check_directory(
577
+ target_path, exclude_patterns=exclude
578
+ )
579
+ all_results.update(directory_results)
580
+
564
581
  except Exception as e:
565
582
  console.print(_red(f"Error during checking: {e}"))
566
583
  raise Exit(1)
567
584
 
568
585
  # Display results
569
- exit_code: int = _display_results(results, quiet, output, check)
586
+ exit_code: int = _display_results(all_results, quiet, output, check)
570
587
 
571
588
  # Always exit with error code if issues are found, regardless of check flag
572
589
  if exit_code != 0:
@@ -584,7 +601,7 @@ def check_docstrings(
584
601
  @app.callback(invoke_without_command=True)
585
602
  def main(
586
603
  ctx: Context,
587
- path: Optional[str] = Argument(None, help="Path to Python file or directory to check"),
604
+ paths: Optional[list[str]] = Argument(None, help="Path(s) to Python file(s) or directory(s) for DFC to check"),
588
605
  config: Optional[str] = Option(None, "--config", "-f", help="Path to configuration file (TOML format)"),
589
606
  exclude: Optional[list[str]] = Option(
590
607
  None,
@@ -646,8 +663,8 @@ def main(
646
663
  Params:
647
664
  ctx (Context):
648
665
  The context object for the command.
649
- path (Optional[str]):
650
- Path to Python file or directory to check.
666
+ paths (Optional[list[str]]):
667
+ Path(s) to Python file(s) or directory(ies) to check.
651
668
  config (Optional[str]):
652
669
  Path to configuration file (TOML format).
653
670
  exclude (Optional[list[str]]):
@@ -670,8 +687,8 @@ def main(
670
687
  Nothing is returned.
671
688
  """
672
689
 
673
- # If no path is provided, show help
674
- if path is None:
690
+ # If no paths are provided, show help
691
+ if not paths:
675
692
  echo(ctx.get_help())
676
693
  raise Exit(0)
677
694
 
@@ -681,7 +698,7 @@ def main(
681
698
  raise Exit(1)
682
699
 
683
700
  check_docstrings(
684
- path=path,
701
+ paths=paths,
685
702
  config=config,
686
703
  exclude=exclude,
687
704
  quiet=quiet,