Skip to content

Require the future-annotations import with ruff - #41

Open
imnasnainaec wants to merge 2 commits into
mainfrom
ruff-required-future-import
Open

Require the future-annotations import with ruff#41
imnasnainaec wants to merge 2 commits into
mainfrom
ruff-required-future-import

Conversation

@imnasnainaec

@imnasnainaec imnasnainaec commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

Every module under src/ opens with from __future__ import annotations
except _extras.py,
which needs nothing from it, so its absence was invisible. Ruff's isort
required-imports enforces what was being eyeballed, and supplies the missing
import.

The rule is scoped to the package. Tests and scripts mostly do without the
import, and that is their own convention rather than a lapse in this one, so
both are exempted from I002 rather than gaining 15 no-op imports.

What is actually being decided

Whether the convention is worth a linter at all. That is a preference, settled
by argument rather than by any test, which is why a change this small is worth
its own review.

Nothing behavioural turns on it either way. The added import is a no-op in
_extras.pyrequires-python is already >=3.11, where every annotation in
that module evaluates fine without it — so what is on offer is the guarantee
that the next module cannot quietly omit it, against a cost of one config
block.

ruff check, ruff format --check and mypy are green.

🤖 Generated with Claude Code


This change is Reviewable

Every module under src/ carries `from __future__ import annotations` except
_extras, which needs nothing from it and so went unnoticed. Ruff's isort
required-imports enforces what was being eyeballed, and adds the import there.

The rule is scoped to the package: tests and scripts mostly do without it, and
that is their own convention rather than a lapse in this one.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
imnasnainaec added a commit that referenced this pull request Aug 26, 2026
Whether the package's `from __future__ import annotations` convention is worth
enforcing with a linter is a preference, settled by argument rather than by any
test, and it shares nothing with the duplicated implementations the rest of
this branch retires — no other commit here touches pyproject.toml or _extras.

It is proposed on its own in #41 instead, where accepting or rejecting it costs
nothing else.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@imnasnainaec imnasnainaec added the 🟩Low Low-priority PR label Aug 26, 2026
@imnasnainaec
imnasnainaec marked this pull request as ready for review August 26, 2026 19:09
The two ignore lines say what they do, and why those trees are exempt belongs
to the history of the rule rather than sitting beside it in the config.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@imnasnainaec imnasnainaec changed the title Require the future-annotations import with ruff, rather than by eye Require the future-annotations import with ruff Aug 26, 2026
@imnasnainaec imnasnainaec self-assigned this Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🟩Low Low-priority PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant