Skip to content

chore(lint): add ruff config and Python lint workflow (closes #101)#105

Merged
wesleysimplicio merged 1 commit into
mainfrom
claude/issue-101-ruff-lint
Jun 2, 2026
Merged

chore(lint): add ruff config and Python lint workflow (closes #101)#105
wesleysimplicio merged 1 commit into
mainfrom
claude/issue-101-ruff-lint

Conversation

@wesleysimplicio
Copy link
Copy Markdown
Owner

Resumo

Fecha #101. Adiciona linter Python (ruff) + workflow CI dedicado.

Mudanças

  • pyproject.toml — bloco [tool.ruff] com regras alinhadas aos noqa já usados no código (S, BLE) + hygiene padrão (E, F, W, I, B, UP). Ignores justificados por linha. Extra [project.optional-dependencies] dev = ["ruff", "pytest"].
  • .github/workflows/python-lint.yml — novo workflow rodando ruff check simplicio_mapper tests/python em push/PR. Bloqueia merge se violar.
  • Auto-fixes do ruff aplicados em cli.py, mapper.py, cache.py, _native.py: import sorting, remoção de mode="r" redundante, encoding="utf-8" redundante em .encode(), troca de typing.Callable/Sequence por collections.abc.*.
  • S603/S607 (subprocess git) já tinha noqa em uma linha e é intencional em todas as outras — adicionado ao ignore global do ruff com rationale documentado.

Fora de escopo

Validação

Item Resultado
ruff check simplicio_mapper tests/python ✅ All checks passed
Python unittest ✅ 30 pass (1 falha pré-existente do container: git commit no fixture rejeitado pelo signing server — fora do escopo desta PR)
npm run lint ✅ 0 erros

Refs #101, #97.

https://claude.ai/code/session_01JdmemqddwFnvbceWyuDE8m


Generated by Claude Code

Closes #101.

Adds a ruff configuration to pyproject.toml selecting the rule set that matches
the existing in-code `noqa` codes (S, BLE) plus the conventional hygiene
families (E, F, W, I, B, UP). Adds a dev extra (`pip install -e .[dev]`) so
contributors install ruff and pytest reproducibly. Adds a dedicated
`python-lint.yml` workflow that runs `ruff check simplicio_mapper tests/python`
on push and pull_request and blocks merge on violations.

Applies the surgical fixes ruff surfaced on first run (import sorting,
unnecessary `mode` arguments, redundant utf-8 encodings, switch to
`collections.abc.Callable` / `Sequence`). The intentional `git` subprocess
invocations are covered by an explicit `S603`/`S607` ignore list with a
documented rationale, matching the existing `# noqa: S603` annotation on
`cli.py`.

A separate Python CI job covering the full pytest matrix and the Rust crate is
tracked in #97; this PR delivers the lint half so the rule set itself is
enforced from day one.

https://claude.ai/code/session_01JdmemqddwFnvbceWyuDE8m
wesleysimplicio pushed a commit that referenced this pull request Jun 2, 2026
The first run of #107 surfaced two issues:

1. `pip install -e ".[dev]"` warned `does not provide the extra 'dev'` because
   the dev extra ships in #105, which has not landed yet, so pytest was never
   installed and the matrix failed with `No module named pytest`.
2. `maturin develop` aborted with "Couldn't find a virtualenv" because the
   GitHub-hosted Python environment is not a venv.

Fix:
- Replace `.[dev]` with explicit `pip install pytest` (and `-e .`) in
  python-ci.yml and the publish-pypi.yml pre-publish step. The dev extra is a
  contributor convenience; CI does not need it.
- Wrap the maturin step in a fresh `python -m venv .venv` + `source activate`
  so maturin has somewhere to install the editable extension.

https://claude.ai/code/session_01JdmemqddwFnvbceWyuDE8m
@wesleysimplicio wesleysimplicio marked this pull request as ready for review June 2, 2026 13:27
Copilot AI review requested due to automatic review settings June 2, 2026 13:27
@wesleysimplicio wesleysimplicio merged commit ac5366d into main Jun 2, 2026
31 checks passed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Python linting via ruff to close #101: introduces a [tool.ruff] config in pyproject.toml, a dedicated CI workflow, and applies safe auto-fixes (import sorting, redundant mode="r"/encoding="utf-8" removals, typing.Callable/Sequencecollections.abc).

Changes:

  • New .github/workflows/python-lint.yml running ruff check on push/PR to main/develop.
  • pyproject.toml: dev extras + [tool.ruff] rule selection/ignores aligned with existing # noqa codes.
  • Auto-fixes applied across cli.py, mapper.py, cache.py, _native.py.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
.github/workflows/python-lint.yml New CI workflow running ruff check on Python sources/tests.
pyproject.toml Adds dev extra with ruff/pytest and full [tool.ruff] lint/format config.
simplicio_mapper/cli.py Import sort, drop redundant "r"/encoding args, Sequence from collections.abc.
simplicio_mapper/mapper.py Callable moved to collections.abc, drop redundant "r" in open.
simplicio_mapper/cache.py Forward-ref string removed for __enter__, drop redundant encoding="utf-8" in .encode().
simplicio_mapper/_native.py Callable moved to collections.abc; split native import into two statements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants