Skip to content

Commit 07d5a8f

Browse files
elifarleyclaude
andcommitted
Fix code formatting issues for CI compliance
- Apply black formatter to fix line length and quote consistency issues - Remove unused imports flagged by ruff linter - Ensure all code passes CI formatting and linting checks - Files updated: src/cedarmapper/cli/main.py, src/cedarmapper/render/flat.py, src/cedarmapper/render/tree.py, src/cedarmapper/render/utils.py, tests/test_cli.py, tests/test_line_limiting.py 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 1723dab commit 07d5a8f

6 files changed

Lines changed: 44 additions & 27 deletions

File tree

src/cedarmapper/cli/main.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -182,20 +182,24 @@ def normalize_date_format(date_format: str) -> str:
182182

183183
# Handle first character shortcuts (case-insensitive)
184184
if len(date_format) == 1:
185-
if date_format.lower() == 's':
185+
if date_format.lower() == "s":
186186
return "seconds"
187-
elif date_format.lower() == 'd':
187+
elif date_format.lower() == "d":
188188
return "day"
189189
else:
190-
raise click.BadParameter(f"Invalid date format '{date_format}'. Use 's'/'d' or 'seconds'/'day'.")
190+
raise click.BadParameter(
191+
f"Invalid date format '{date_format}'. Use 's'/'d' or 'seconds'/'day'."
192+
)
191193

192194
# Handle full words (case-insensitive)
193195
if date_format.lower() in ("seconds", "second"):
194196
return "seconds"
195197
elif date_format.lower() in ("day", "days"):
196198
return "day"
197199
else:
198-
raise click.BadParameter(f"Invalid date format '{date_format}'. Use 's'/'d' or 'seconds'/'day'.")
200+
raise click.BadParameter(
201+
f"Invalid date format '{date_format}'. Use 's'/'d' or 'seconds'/'day'."
202+
)
199203

200204

201205
@click.group()
@@ -214,7 +218,11 @@ def cli() -> None:
214218
help="Display max depth: 0=root only, 1=root+children, etc.",
215219
)
216220
@click.option(
217-
"--tree", "-t", is_flag=True, default=False, help="Show tree-like nested output (human-friendly)."
221+
"--tree",
222+
"-t",
223+
is_flag=True,
224+
default=False,
225+
help="Show tree-like nested output (human-friendly).",
218226
)
219227
@click.option(
220228
"--follow-symlinks", is_flag=True, default=False, help="Follow symbolic links during traversal."
@@ -343,7 +351,8 @@ def ls(
343351

344352
# Calculate explicit_date_format: user explicitly set date-format parameter if it came from command line
345353
from click.core import ParameterSource
346-
explicit_date_format = ctx.get_parameter_source('date_format') == ParameterSource.COMMANDLINE
354+
355+
explicit_date_format = ctx.get_parameter_source("date_format") == ParameterSource.COMMANDLINE
347356

348357
if tree:
349358
out = render_tree(
@@ -416,6 +425,7 @@ def preprocess_click_args(args: list[str]) -> list[str]:
416425
def main_with_preprocess() -> None:
417426
"""Main entry point with -N format preprocessing."""
418427
import sys
428+
419429
# Preprocess args before passing to Click
420430
processed_args = preprocess_click_args(sys.argv[1:])
421431
cli(processed_args)

src/cedarmapper/render/flat.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
format_header_row,
1414
format_separator_row,
1515
format_totals_row,
16-
get_column_specs,
1716
)
1817

1918

@@ -164,15 +163,17 @@ def _render_node(node: DirInfo | FileInfo, depth: int, parent_path: str) -> None
164163

165164
# Create a minimal DirInfo with totals from limited rows
166165
total_size = sum(r.obj.size_bytes for r in limited_rows)
167-
total_word_count = sum(r.obj.word_count for r in limited_rows if r.obj.word_count is not None)
166+
total_word_count = sum(
167+
r.obj.word_count for r in limited_rows if r.obj.word_count is not None
168+
)
168169
latest_mtime = max((r.obj.mtime for r in limited_rows), default=datetime.min)
169170

170171
limited_root = DirInfo(
171172
path=root.path,
172173
size_bytes=total_size,
173174
word_count=total_word_count,
174175
mtime=latest_mtime,
175-
children=[] # Children not needed for totals
176+
children=[], # Children not needed for totals
176177
)
177178
lines.append(format_totals_row(column_specs, limited_root, show_path=show_path))
178179
else:

src/cedarmapper/render/tree.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
format_header_row,
1313
format_separator_row,
1414
format_totals_row,
15-
get_column_specs,
1615
)
1716

1817

src/cedarmapper/render/utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,15 @@ def _fmt_count(c: int | None) -> str:
127127
return "-" if c is None else str(c)
128128

129129

130-
def format_data_row(config: DisplayConfig, node: FileInfo | DirInfo, path: str, prefix: str = "") -> str:
130+
def format_data_row(
131+
config: DisplayConfig, node: FileInfo | DirInfo, path: str, prefix: str = ""
132+
) -> str:
131133
"""Format a single data row based on display configuration."""
132134
columns = []
133135

134136
# Words column
135137
if config.should_show_words():
136-
word_count = getattr(node, 'word_count', None)
138+
word_count = getattr(node, "word_count", None)
137139
columns.append(f"{_fmt_count(word_count):>7}")
138140

139141
# Size column

tests/test_cli.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -232,13 +232,9 @@ def test_cli_line_limit_with_other_click_options(self):
232232
(tmppath / "medium.txt").write_text("x" * 100)
233233

234234
# Test combination of Click options
235-
code, out = run_cli([
236-
str(tmppath),
237-
"--tree",
238-
"--max-depth", "1",
239-
"--sort", "-s",
240-
"--line-limit", "2"
241-
])
235+
code, out = run_cli(
236+
[str(tmppath), "--tree", "--max-depth", "1", "--sort", "-s", "--line-limit", "2"]
237+
)
242238
assert code == 0
243239
# Should have basic structure
244240
assert "Words" in out or "Size" in out
@@ -259,6 +255,7 @@ def test_cli_help_shows_git_log_style_documentation(self):
259255
"""Test that help shows git log-style line limiting documentation."""
260256
# Test using the actual CLI command (since --help is handled by Click)
261257
import subprocess
258+
262259
result = subprocess.run(["cedarmapper", "ls", "--help"], capture_output=True, text=True)
263260
assert result.returncode == 0
264261
# Should show tree-only functionality but not --line-limit (we use -N git log style)
@@ -269,6 +266,7 @@ def test_cli_short_aliases_documented(self):
269266
"""Test that short option aliases are documented in help."""
270267
# Test using the actual CLI command (since --help is handled by Click)
271268
import subprocess
269+
272270
result = subprocess.run(["cedarmapper", "ls", "--help"], capture_output=True, text=True)
273271
assert result.returncode == 0
274272
# Check that -t and -n aliases are properly formatted with their long options

tests/test_line_limiting.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ def test_line_limit_basic_functionality(self):
2424
assert code_unlimited == 0
2525

2626
# Test with line limit - should show fewer items
27-
code_limited, out_limited = run_cli([str(tmppath), "--max-depth", "1", "--line-limit", "3"])
27+
code_limited, out_limited = run_cli(
28+
[str(tmppath), "--max-depth", "1", "--line-limit", "3"]
29+
)
2830
assert code_limited == 0
2931

3032
# The limited output should be shorter than unlimited output
@@ -79,12 +81,17 @@ def test_line_limit_with_sorting(self):
7981
(tmppath / "medium.txt").write_text("x" * 100)
8082

8183
# Test combination of line limiting and sorting
82-
code, out = run_cli([
83-
str(tmppath),
84-
"--max-depth", "1",
85-
"--sort", "-s", # Sort by size descending
86-
"--line-limit", "2"
87-
])
84+
code, out = run_cli(
85+
[
86+
str(tmppath),
87+
"--max-depth",
88+
"1",
89+
"--sort",
90+
"-s", # Sort by size descending
91+
"--line-limit",
92+
"2",
93+
]
94+
)
8895
assert code == 0
8996
# Should have basic structure
9097
assert "Words" in out or "Size" in out
@@ -117,4 +124,4 @@ def test_both_formats_work_equivalently(self):
117124
# Both should produce the same line count
118125
lines1 = len(out1.strip().splitlines())
119126
lines2 = len(out2.strip().splitlines())
120-
assert lines1 == lines2
127+
assert lines1 == lines2

0 commit comments

Comments
 (0)