Skip to content

Commit ec17ea4

Browse files
author
Hermes Agent
committed
fix: resolve 18 ruff lint errors, add ruff CI step, remove npm-publish.yml
- Fix 13 unused import errors (F401) across cli.py, converters.py, tests - Fix 1 f-string without placeholders (F541) in cli.py - Fix 5 import ordering errors (I001) across all source files - Fix 1 line-too-long (E501) in cli.py validate command decorator - Add [tool.ruff] config to pyproject.toml (target py310, line-length 120) - Add lint job to CI (test.yml) with ruff check step, test depends on lint - Remove npm-publish.yml (incorrect for Python project, has publish.yml for PyPI)
1 parent 7424dc9 commit ec17ea4

8 files changed

Lines changed: 36 additions & 46 deletions

File tree

.github/workflows/npm-publish.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,25 @@ on:
77
branches: [master]
88

99
jobs:
10+
lint:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v6
14+
15+
- name: Set up Python
16+
uses: actions/setup-python@v6
17+
with:
18+
python-version: "3.12"
19+
20+
- name: Install ruff
21+
run: pip install ruff
22+
23+
- name: Run ruff check
24+
run: ruff check .
25+
1026
test:
1127
runs-on: ubuntu-latest
28+
needs: lint
1229
strategy:
1330
matrix:
1431
python-version: ["3.10", "3.11", "3.12", "3.13"]

conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
# Add user site-packages for dependencies installed outside venv
1010
import site
11+
1112
user_site = site.getusersitepackages()
1213
if user_site and user_site not in sys.path:
1314
sys.path.insert(0, user_site)

pyproject.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ datamorph = "datamorph.cli:cli"
4747
[tool.setuptools.packages.find]
4848
where = ["src"]
4949

50+
[tool.ruff]
51+
target-version = "py310"
52+
line-length = 120
53+
54+
[tool.ruff.lint]
55+
select = ["E", "F", "W", "I"]
56+
5057
[tool.pytest.ini_options]
5158
testpaths = ["tests"]
5259
python_files = ["test_*.py"]

src/datamorph/cli.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@
44

55
import json
66
import sys
7-
from pathlib import Path
87
from typing import Any
98

109
import click
1110
from rich.console import Console
1211
from rich.table import Table
1312

1413
from . import __version__
14+
1515
try:
1616
from revenueholdings_core import check_license_and_limit
1717
except ImportError:
1818
check_license_and_limit = None
1919
from .converters import (
2020
convert,
2121
convert_batch,
22-
supported_formats,
2322
detect_format,
23+
supported_formats,
2424
validate,
2525
)
2626

@@ -144,7 +144,7 @@ def batch_cmd(
144144
success = [r for r in results if not r.errors]
145145
failed = [r for r in results if r.errors]
146146

147-
console.print(f"\n[bold]Batch Conversion Complete[/bold]")
147+
console.print("\n[bold]Batch Conversion Complete[/bold]")
148148
console.print(f" Files: {len(success)} converted, {len(failed)} failed")
149149

150150
if failed:
@@ -231,7 +231,10 @@ def formats_cmd() -> None:
231231
@cli.command()
232232
@click.argument("file", type=click.Path(exists=True))
233233
@click.option("--format", "-f", "fmt", default=None, help="File format (auto-detected if omitted)")
234-
@click.option("--schema", "-s", "schema_file", default=None, type=click.Path(exists=True), help="JSON schema file to validate against")
234+
@click.option(
235+
"--schema", "-s", "schema_file", default=None,
236+
type=click.Path(exists=True), help="JSON schema file to validate against",
237+
)
235238
@click.option("--strict", is_flag=True, help="Strict mode: fail on type mismatches and missing fields")
236239
@click.option("--max-rows", default=0, type=int, help="Maximum rows to validate (0 = all)")
237240
@click.option("--json-output", "-j", is_flag=True, help="Output validation result as JSON")

src/datamorph/converters.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,11 @@
77
from __future__ import annotations
88

99
import csv
10-
import io
1110
import json
12-
import os
13-
import sys
1411
from abc import ABC, abstractmethod
1512
from dataclasses import dataclass, field
1613
from pathlib import Path
17-
from typing import Any, Callable, Generator, Iterator
14+
from typing import Any, Generator
1815

1916
# ── Types ────────────────────────────────────────────────────────────
2017

tests/test_converters.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,17 @@
33
from __future__ import annotations
44

55
import json
6-
import os
7-
import tempfile
8-
from pathlib import Path
96

107
import pytest
118
import yaml
129

10+
from datamorph.cli import cli
1311
from datamorph.converters import (
1412
convert,
1513
detect_format,
16-
supported_formats,
1714
get_reader,
18-
get_writer,
19-
Row,
15+
supported_formats,
2016
)
21-
from datamorph.cli import cli
2217

2318
# ── Fixtures ──────────────────────────────────────────────────────────
2419

tests/test_validate.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@
33
from __future__ import annotations
44

55
import json
6-
from pathlib import Path
76

87
import pytest
98

10-
from datamorph.converters import validate, ValidationResult
119
from datamorph.cli import cli
12-
10+
from datamorph.converters import ValidationResult, validate
1311

1412
# ── Fixtures ──────────────────────────────────────────────────────────
1513

0 commit comments

Comments
 (0)