Skip to content

Commit cb87db1

Browse files
committed
style: Format head, tail, and validate commands with ruff
1 parent 83c5e6a commit cb87db1

4 files changed

Lines changed: 16 additions & 12 deletions

File tree

.claude/settings.local.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"Bash(gh issue create:*)",
1414
"Bash(uv run mypy:*)",
1515
"Bash(uv run ruff check:*)",
16-
"Bash(uv run ruff format:*)"
16+
"Bash(uv run ruff format:*)",
17+
"Bash(git rm:*)"
1718
]
1819
}
1920
}

excel_toolkit/commands/head.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ def head(
6767

6868
# 5. Display file info
6969
path = Path(file_path)
70-
typer.echo(format_file_info(str(path), sheet=sheet, total_rows=len(df), total_cols=len(df.columns)))
70+
typer.echo(
71+
format_file_info(str(path), sheet=sheet, total_rows=len(df), total_cols=len(df.columns))
72+
)
7173

7274
# 6. Show column information if requested
7375
if show_columns:

excel_toolkit/commands/tail.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ def tail(
6767

6868
# 5. Display file info
6969
path = Path(file_path)
70-
typer.echo(format_file_info(str(path), sheet=sheet, total_rows=len(df), total_cols=len(df.columns)))
70+
typer.echo(
71+
format_file_info(str(path), sheet=sheet, total_rows=len(df), total_cols=len(df.columns))
72+
)
7173

7274
# 6. Show column information if requested
7375
if show_columns:

excel_toolkit/commands/validate.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
def validate(
1818
file_path: str = typer.Argument(..., help="Path to input file"),
1919
rules: str | None = typer.Option(
20-
None, "--rules", help="Validation rules (format: col:type or col:type:min-max or col:pattern or col:required or col:unique)"
20+
None,
21+
"--rules",
22+
help="Validation rules (format: col:type or col:type:min-max or col:pattern or col:required or col:unique)",
2123
),
2224
rules_file: str | None = typer.Option(
2325
None, "--rules-file", help="JSON file with validation rules"
@@ -274,7 +276,7 @@ def validate(
274276
if not rules_list:
275277
typer.echo(
276278
"Error: No validation rules specified. Use --rules, --columns, --types, --range, --unique, or --null-threshold",
277-
err=True
279+
err=True,
278280
)
279281
typer.echo("Run 'xl validate --help' for examples")
280282
raise typer.Exit(1)
@@ -292,9 +294,7 @@ def validate(
292294
if email_columns:
293295
import re
294296

295-
email_pattern = re.compile(
296-
r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'
297-
)
297+
email_pattern = re.compile(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$")
298298

299299
for email_col in email_columns:
300300
if email_col not in df.columns:
@@ -305,9 +305,7 @@ def validate(
305305
if pd.notna(value):
306306
value_str = str(value).strip()
307307
if value_str and not email_pattern.match(value_str):
308-
invalid_emails.append(
309-
{"row": idx, "value": value_str}
310-
)
308+
invalid_emails.append({"row": idx, "value": value_str})
311309

312310
if invalid_emails:
313311
# Add email pattern errors to the report
@@ -365,7 +363,8 @@ def validate(
365363
# Only exit with code 1 if there are actual critical errors (not just type mismatches)
366364
# Type mismatches (column_type) are considered warnings for data quality validation
367365
critical_errors = [
368-
e for e in report.errors
366+
e
367+
for e in report.errors
369368
if e.get("type") != "column_type" # Filter out type mismatches, keep pattern errors
370369
]
371370
if critical_errors:

0 commit comments

Comments
 (0)