← Back to issue list

fix: resolve ruff and ty lint findings

View original Github issue

Metadata

Project
craft-store
Number
#441
Type
pull request
State
closed
Author
lengau
Labels
—
Created
Updated
Closed

Current evaluation

Merged to fix ruff and ty lint findings (import ordering, type-checking imports, ty model fields) in preparation for the Starbase sync PR #440.

Resolution: closed resolved

Reason: The PR was merged to address lint violations and prepare the codebase for the Starbase configuration sync in #440.

Evaluated by: mr-cal-bot

No scores available.

Issue body

## 🤖 [BEEP BOOP, A BOT WROTE THIS DESCRIPTION - Step 5, opencode] Preparation PR for the Starbase sync in #440. Fixes the lint findings that `make lint` currently reports, so that the `lint / files` CI job passes. ### Why this is separate from #440 The Starbase merge in #440 adopts Starbase's expanded `tool.ruff.lint.select`, which adds `ASYNC`, `S*`, `FBT`, `COM`, `PIE*`, `SLF`, `TID`, `TC001`–`TC003`, `FIX`, `FLY`, `PERF`, `B035`, `RUF001`–`RUF013`, `RUF100` and `RUF200`. Several of those findings **already fire on `main` today** (`ICN001` is in `main`'s current `select`), and the rest surface once the merge lands. Per the preparation-PR rules these fixes belong in their own PR rather than bundled into the merge, so they can be reviewed and reverted independently. #440 stays in draft until this PR is merged. ### What's in it **Source fixes** | Finding | Where | Fix | |---|---|---| | `ICN001` (11) | 14 files in `craft_store/` and `tests/` | Adopt the `import datetime as dt` alias convention | | `TC002` | `craft_store/errors.py` | Move `requests` into a `TYPE_CHECKING` block | | `TC003` (2) | `craft_store/publisher/_publishergw.py` | Move `Collection`/`Sequence` into a `TYPE_CHECKING` block | | `PERF401` | `craft_store/errors.py` | List comprehension in `StoreErrorList.__str__` | | `RUF100` | `craft_store/creds.py` | Remove a stale `# noqa: ANN401` | | `ty` (2) | `tests/integration/test_upload.py`, `tests/unit/models/test_track_guardrail_model.py` | Pass model fields by their Python names instead of hyphenated alias dicts | The `TYPE_CHECKING` moves are safe: both modules already use `from __future__ import annotations` and the moved imports are used in annotations only. All modules still import cleanly. The `ty` fixes are behaviour-identical — `MarshableModel` sets `populate_by_name = True` (`craft_store/models/_base_model.py:28-33`), so `upload_id=` and `created_at=` resolve to the same fields as the alias dicts they replace. **Config additions** — new entries in `tool.ruff.lint.ignore` (child-owned values, per the ownership map): - `ANN401` — `Any` is used deliberately for forwarded keyword arguments (e.g. the `**kwargs` in `Credentials.model_validate_json`, which forwards to pydantic). - `FBT001`, `FBT002` — boolean positional arguments are part of this library's **public API** (`Auth.__init__`, `Auth.set_credentials`, `PublisherGateway.list_registered_names`). Making them keyword-only would break downstream craft apps, and backward compatibility is a hard requirement for this repository. - `FIX002` — TODOs in this repository are tracked outside the repo, not as issues. - `SLF001` — `httpbakery._interactor` has no public alternative; this code is pending migration to macaroonbakery (see the `TODO` in `store_client.py`). ### Validation | Check | Result | |---|---| | `ruff check craft_store tests` | **PASS** | | `ruff format --check craft_store tests` | **PASS** | | `ty check craft_store tests` | **PASS** | | `make test-fast` | **PASS** — 266 passed | Also verified clean against the merged `tool.ruff` config from #440, so nothing regresses once the merge lands. ### Note `make docs` fails identically on `main` with `find: '../.venv/lib/python*/site-packages/vale/vale_bin': No such file or directory`. This is pre-existing and environmental, not addressed here.

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.6-35b-a3b — closed resolved Merged to fix ruff and ty lint findings (import ordering, type-checking imports, ty model fields) in preparation for the Starbase sync PR #440.

Update history

Date Change
closed
updated
updated
updated
updated
created

Related work

  • Likely Fixed By: craft-store#440 (confidence 95%)

    Explicitly described as a preparation PR for the Starbase sync in #440.

Related issues

Issue Project State Summary Similarity
#444 fix: resolve ruff and ty lint findings craft-store merged Merged to fix ruff and ty lint findings and update ruff config, preparing for the Starbase sync in #440.
91%
#287 fix: Typos in doc and make files starbase merged Merged PR #287 as commit 2a0a524, fixing typos in starbase documentation and Makefile. Author noted it was held until #288 (ruff-pre-commit v0.8.1 update) fixed the failing linter check.
75%
#95 Merge starbase craft-archives closed Merged Starbase into main via PR #95, including Ruff formatting, relaxed fixture() enforcement, and manual fixes.
74%
#55 lint: stricter ruff rules starbase merged Merged PR canonical/starbase#55 as b5cda0d, tightening Ruff lint rules in one file (+23/-9) after maintainer approval.
73%
#4712 Move more linting to ruff snapcraft closed Ruff linting was completed and aligned with Starbase; pylint and isort were removed in #4817 and commit a00f1c439, followed by pylint cleanup in #4848.
72%
#165 style: fix linting for ruff 0.12 imagecraft merged Merged #165, incorporating canonical/starbase#408, with a four-file Ruff 0.12 compatibility style update (+7/-7).
72%
#588 chore: use the latest ruff config from starbase craft-application merged Merged PR #588 as commit 44b1a940, adopting starbase's latest Ruff configuration and updating linting across 86 files for the Starflow migration.
72%
#327 ci: update comments for linting and typing issues craft-providers merged Merged #327 as 56868d1, updating inline comments to reference linting issue #325 and typing issue #326 after the Starbase sync.
71%
#1228 style: fix ruff and ty lint errors craft-application merged Merged PR #1228 fixing ruff and ty lint errors, including datetime import aliasing, shadowed imports, invalid ClassVar overrides, and deprecated contextmanager annotations.
71%
#20 style: fix ruff issue craft-platforms merged Merged PR #20 fixed a Ruff linting issue in one file (+1/-3); resolution is commit 71a165d.
71%