From ec17ea4311ffae41e6852802ec570d8072249ef2 Mon Sep 17 00:00:00 2001 From: Hermes Agent Date: Mon, 18 May 2026 00:53:08 -0400 Subject: [PATCH] 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) --- .github/workflows/npm-publish.yml | 28 ---------------------------- .github/workflows/test.yml | 17 +++++++++++++++++ conftest.py | 1 + pyproject.toml | 7 +++++++ src/datamorph/cli.py | 11 +++++++---- src/datamorph/converters.py | 5 +---- tests/test_converters.py | 9 ++------- tests/test_validate.py | 4 +--- 8 files changed, 36 insertions(+), 46 deletions(-) delete mode 100644 .github/workflows/npm-publish.yml diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml deleted file mode 100644 index ffc3b66..0000000 --- a/.github/workflows/npm-publish.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Publish to npm - -on: - release: - types: [published] - workflow_dispatch: - -jobs: - publish: - runs-on: ubuntu-latest - permissions: - contents: read - - steps: - - uses: actions/checkout@v6 - - - name: Set up Node.js - uses: actions/setup-node@v6 - with: - node-version: "22" - registry-url: "https://registry.npmjs.org" - - - name: Publish to npm - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - run: | - npm publish --access public - diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index eed9856..676f2d9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,8 +7,25 @@ on: branches: [master] jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + + - name: Set up Python + uses: actions/setup-python@v6 + with: + python-version: "3.12" + + - name: Install ruff + run: pip install ruff + + - name: Run ruff check + run: ruff check . + test: runs-on: ubuntu-latest + needs: lint strategy: matrix: python-version: ["3.10", "3.11", "3.12", "3.13"] diff --git a/conftest.py b/conftest.py index 00b6696..c9861f1 100644 --- a/conftest.py +++ b/conftest.py @@ -8,6 +8,7 @@ # Add user site-packages for dependencies installed outside venv import site + user_site = site.getusersitepackages() if user_site and user_site not in sys.path: sys.path.insert(0, user_site) diff --git a/pyproject.toml b/pyproject.toml index a78680b..9cc5ca7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -47,6 +47,13 @@ datamorph = "datamorph.cli:cli" [tool.setuptools.packages.find] where = ["src"] +[tool.ruff] +target-version = "py310" +line-length = 120 + +[tool.ruff.lint] +select = ["E", "F", "W", "I"] + [tool.pytest.ini_options] testpaths = ["tests"] python_files = ["test_*.py"] \ No newline at end of file diff --git a/src/datamorph/cli.py b/src/datamorph/cli.py index 5a10bab..daeb0ed 100644 --- a/src/datamorph/cli.py +++ b/src/datamorph/cli.py @@ -4,7 +4,6 @@ import json import sys -from pathlib import Path from typing import Any import click @@ -12,6 +11,7 @@ from rich.table import Table from . import __version__ + try: from revenueholdings_core import check_license_and_limit except ImportError: @@ -19,8 +19,8 @@ from .converters import ( convert, convert_batch, - supported_formats, detect_format, + supported_formats, validate, ) @@ -144,7 +144,7 @@ def batch_cmd( success = [r for r in results if not r.errors] failed = [r for r in results if r.errors] - console.print(f"\n[bold]Batch Conversion Complete[/bold]") + console.print("\n[bold]Batch Conversion Complete[/bold]") console.print(f" Files: {len(success)} converted, {len(failed)} failed") if failed: @@ -231,7 +231,10 @@ def formats_cmd() -> None: @cli.command() @click.argument("file", type=click.Path(exists=True)) @click.option("--format", "-f", "fmt", default=None, help="File format (auto-detected if omitted)") -@click.option("--schema", "-s", "schema_file", default=None, type=click.Path(exists=True), help="JSON schema file to validate against") +@click.option( + "--schema", "-s", "schema_file", default=None, + type=click.Path(exists=True), help="JSON schema file to validate against", +) @click.option("--strict", is_flag=True, help="Strict mode: fail on type mismatches and missing fields") @click.option("--max-rows", default=0, type=int, help="Maximum rows to validate (0 = all)") @click.option("--json-output", "-j", is_flag=True, help="Output validation result as JSON") diff --git a/src/datamorph/converters.py b/src/datamorph/converters.py index 42c456f..187afeb 100644 --- a/src/datamorph/converters.py +++ b/src/datamorph/converters.py @@ -7,14 +7,11 @@ from __future__ import annotations import csv -import io import json -import os -import sys from abc import ABC, abstractmethod from dataclasses import dataclass, field from pathlib import Path -from typing import Any, Callable, Generator, Iterator +from typing import Any, Generator # ── Types ──────────────────────────────────────────────────────────── diff --git a/tests/test_converters.py b/tests/test_converters.py index c3c45bd..9ec63a3 100644 --- a/tests/test_converters.py +++ b/tests/test_converters.py @@ -3,22 +3,17 @@ from __future__ import annotations import json -import os -import tempfile -from pathlib import Path import pytest import yaml +from datamorph.cli import cli from datamorph.converters import ( convert, detect_format, - supported_formats, get_reader, - get_writer, - Row, + supported_formats, ) -from datamorph.cli import cli # ── Fixtures ────────────────────────────────────────────────────────── diff --git a/tests/test_validate.py b/tests/test_validate.py index 599228f..99964b5 100644 --- a/tests/test_validate.py +++ b/tests/test_validate.py @@ -3,13 +3,11 @@ from __future__ import annotations import json -from pathlib import Path import pytest -from datamorph.converters import validate, ValidationResult from datamorph.cli import cli - +from datamorph.converters import ValidationResult, validate # ── Fixtures ──────────────────────────────────────────────────────────