Update parse_cli docstring (#646)

This commit is contained in:
Glenn Jocher
2025-11-09 11:10:10 +00:00
committed by GitHub
parent e8e87e4721
commit 7be11d365a
2 changed files with 16 additions and 11 deletions
+9 -4
View File
@@ -574,13 +574,18 @@ def run(files: list[Path], width: int, check: bool, start_newline: bool, workers
def parse_cli(argv: list[str]) -> tuple[list[Path], int, bool, bool]:
"""Parse command-line arguments.
Processes CLI arguments to extract paths and formatting options. Supports '--check' for validation mode,
'--start-newline' to force docstring summaries on new lines, and '--line-width=N' to set maximum line width.
Non-flag arguments are treated as file or directory paths.
Args:
--check: Check if files would be reformatted without modifying them.
--start-newline: Force docstring summaries to start on a newline after opening quotes.
--line-width=N: Set maximum line width (default: 120).
argv: List of command-line argument strings.
Returns:
(paths, width, check, start_newline)
paths: List of Path objects to process.
width: Maximum line width for formatting (default 120).
check: Bool for dry-run mode.
start_newline: Bool controlling docstring summary placement.
"""
width, check, paths, start_newline = 120, False, [], False
for a in argv:
+7 -7
View File
@@ -146,14 +146,14 @@ def update_file(file_path, prefix, block_start, block_end, base_header):
if content_start < len(lines) and not lines[content_start].strip():
content_start += 1
content_lines = lines[content_start:]
# No header found
elif special_line_index >= 0:
# Content starts after special line
content_lines = lines[special_line_index + 1 :]
else:
# No header found
if special_line_index >= 0:
# Content starts after special line
content_lines = lines[special_line_index + 1 :]
else:
# No special line, content starts at beginning
content_lines = lines
# No special line, content starts at beginning
content_lines = lines
# Add blank line if the first content line isn't blank and isn't a docstring
if content_lines and content_lines[0].strip() and not content_lines[0].strip().startswith('"""'):