Skip to content

fix(python): clear ruff findings and pin the linter to a minor series - #123

Merged
yfedoseev merged 2 commits into
mainfrom
fix/ruff-lint-debt
Aug 29, 2026
Merged

fix(python): clear ruff findings and pin the linter to a minor series#123
yfedoseev merged 2 commits into
mainfrom
fix/ruff-lint-debt

Conversation

@yfedoseev

Copy link
Copy Markdown
Owner

Why every dependabot PR is red

The Lint and Format Check job (.github/workflows/python.yml:120) runs uv run ruff check python/ and reports "Found 31 errors" — on every open PR, including bumps that touch no Python at all. It fails identically on a Rust-only bump (#117) and a CI-action-only bump (#101), which is what shows it isn't the bumps.

The cause is the dependency declaration, not the code:

dev = ["maturin>=1.0", "pytest>=7.0", "ruff>=0.4"]

Unpinned, so CI resolves whatever ruff published most recently — 0.16.4 today — and each release turns on new default rules. The gate changed under the repo with no commit, and all 11 open dependabot PRs went red together. (Locally I had ruff 0.14.6 and ruff check python/ passed, which is exactly how this stayed invisible.)

What's in here

1. Fix the 31 findings. 29 were in the _native.pyi stub:

rule fix
PYI044 drop from __future__ import annotations — no effect in stubs
PYI026 ×3 give FormatName / _Path / _CellValue an explicit TypeAlias
UP037 + PYI020 ×5 unquote the forward references
PYI034 ×2 __enter__ returns Self
PYI036 ×2, UP045 ×7, UP006 ×2, UP007 ×2 `type[BaseException]

PEP 604/585 syntax appears only in the stub, where it's valid regardless of the requires-python = ">=3.8" runtime floor — stubs aren't evaluated at runtime. The remaining 2 findings were import and __all__ ordering in __init__.py (auto-fixed).

2. Pin ruff>=0.16,<0.17 so a future release can't silently redden every open PR again. Comment in pyproject.toml says why, so nobody widens it back.

Verification

$ uv run --group dev ruff check python/     # the exact CI command
All checks passed!

$ uv run --with mypy mypy python/office_oxide/_native.pyi
Success: no issues found in 1 source file

Also checked that every name in __all__ still resolves to an import from _native after the reordering, and that both files parse. No runtime code changed beyond import/__all__ order; the stub is never imported at runtime.

Effect

This should unblock #101, #105, #106, #107, #108, #109, #112, #113, #114, #117 and #121 in one go. #105#108 additionally carry stale August-12 runs that will want a re-run once this lands.

https://claude.ai/code/session_01QCzrWMwEUtN6B3pN1HSKbb

`ruff check python/` reported 31 errors on every open PR, including
dependency bumps that touch no Python at all. The cause is not the code:
the dev group declared `ruff>=0.4`, so CI resolved whatever ruff had most
recently published — 0.16.4 today — and each release enables new default
rules. The gate therefore changed under the repo with no commit, and all
11 open dependabot PRs went red together.

Two parts:

- Fix the findings. 29 were in the `_native.pyi` stub: drop the no-op
  `from __future__ import annotations` (stubs already have those
  semantics), give the three aliases an explicit `TypeAlias`, unquote the
  forward references, return `Self` from `__enter__`, and annotate
  `__exit__` with `types.TracebackType | None`. PEP 604/585 syntax is
  used only in the stub, where it is valid regardless of the 3.8 runtime
  floor. The remaining 2 were import and `__all__` ordering in
  `__init__.py`.
- Pin `ruff>=0.16,<0.17` so a future release cannot turn every open PR
  red without a code change.

`uv run ruff check python/` — the exact CI command — now passes, and
mypy reports no issues on the stub.

Claude-Session: https://claude.ai/code/session_01QCzrWMwEUtN6B3pN1HSKbb
@yfedoseev

Copy link
Copy Markdown
Owner Author

Correction to the "Effect" section above. Clearing ruff is necessary but not sufficient.

The Lint and Format Check job runs cargo fmtcargo clippy --features python --all-targets -- -D warningsuv run ruff check python/, in that order. Rust 1.98's clippy added chunks_exact_to_as_chunks, which fires twice on main — so the job has been failing at the clippy step and never reaching ruff at all. The "Found 31 errors" output I quoted came from an August-12 run, back when the toolchain still got past clippy.

So this PR fixes the ruff half; #124 fixes the clippy half. Both are needed before the 11 dependabot PRs go green.

Verified on main with no changes applied:

$ cargo clippy --workspace --all-targets -- -D warnings
error: using `chunks_exact` with a constant chunk size  --> src/cfb/reader.rs:43:18
error: using `chunks_exact` with a constant chunk size  --> src/ppt/text.rs:379:10

@yfedoseev
yfedoseev merged commit a74481d into main Aug 29, 2026
74 checks passed
@yfedoseev
yfedoseev deleted the fix/ruff-lint-debt branch August 29, 2026 04:17
yfedoseev added a commit that referenced this pull request Sep 1, 2026
* release: v0.1.9 — legacy .doc tables, lists, and tab stops

Bumps the version across every binding (Rust crates, Python, JS, WASM,
Go installer, C#) and adds the CHANGELOG entry for 0.1.9.

Headline change is legacy binary .doc structure extraction into the IR —
tables (#116) and lists + tab stops (#120), both contributed by
@xugangqiang, closing #115. Also carries the IR list-nesting fix (#122),
the clippy/ruff gate repairs (#123, #124), and a dependency refresh.

Also refreshes stale version literals in the getting-started docs, which
still advertised 0.1.6 (and 0.1.1 for the C# package).

Claude-Session: https://claude.ai/code/session_011Ueq2ge9rTr3aCPsuTiFEs

* chore(release): refresh bench_rust lockfile to 0.1.9

bench_rust is excluded from the workspace but carries a path dependency
on office_oxide, so its lockfile pinned the stale 0.1.8. Not covered by
.github/scripts/check-versions.sh, so it drifted silently across releases.

Claude-Session: https://claude.ai/code/session_011Ueq2ge9rTr3aCPsuTiFEs

* fix(changelog): date 0.1.9 as 2026-09-01 (UTC)

The entry said 2026-08-31, taken from local time (PDT). Every prior
release dates its heading in UTC — v0.1.8, v0.1.7 and v0.1.5 were all
committed in the evening Pacific and dated the following UTC day. It is
already 2026-09-01 in UTC, and the tag/GitHub Release will be stamped
that way too.

Claude-Session: https://claude.ai/code/session_011Ueq2ge9rTr3aCPsuTiFEs
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.

1 participant