Skip to content

Infer Ruff target-version from requires-python#150

Merged
maresb merged 2 commits into
labelle-org:mainfrom
maresb:chore/ruff-infer-target
Jun 1, 2026
Merged

Infer Ruff target-version from requires-python#150
maresb merged 2 commits into
labelle-org:mainfrom
maresb:chore/ruff-infer-target

Conversation

@maresb

@maresb maresb commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #148. With the minimum Python now at 3.10, the Ruff target-version was a second place to keep in sync with requires-python. Ruff derives the target from project.requires-python when target-version is unset, so this PR drops the hardcoded line.

Removing it raises Ruff's inferred target from py38 to py310, which enables the pyupgrade rules already in the select list (UP006/UP035/UP045/UP007). The resulting modernization is applied in its own commit.

Commits (atomic)

  1. Modernize type hints to Python 3.10+ syntax — PEP 604 unions (X | None) and PEP 585 builtin generics (list[str]), dropping the corresponding typing imports. Applied automatically via Ruff --fix --unsafe-fixes, then ruff format. 11 files, no manual edits.
  2. Infer Ruff target-version from requires-python — the one-line config removal.

Splitting these keeps the mechanical churn separate from the config decision, and each commit is independently lint-clean.

Verification

  • ruff check and ruff format --check pass on all tracked sources.
  • mypy passes (pre-commit).
  • CLI smoke test against a fresh install: labelle --version and labelle --help exit 0, and typer correctly introspects the new annotations (e.g. list[str] | NoneTEXT, int | NoneINTEGER). The --font and other options render as before.

🤖 Generated with Claude Code

maresb and others added 2 commits June 1, 2026 18:32
Now that the minimum is Python 3.10, switch to PEP 604 unions
(X | None) and PEP 585 builtin generics (list[str]) and drop the
corresponding typing imports. Applied automatically via ruff's pyupgrade
rules (UP006, UP035, UP045, UP007). This is a prerequisite for letting
ruff infer its target version from requires-python.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Drop the hardcoded target-version from the Ruff config. When it is
unset, Ruff derives the minimum supported Python version from the
project's requires-python (>=3.10), so there is no second place to keep
in sync when the supported range changes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR aligns Ruff’s Python targeting with the project’s declared supported Python range (3.10+) by relying on project.requires-python, and applies the resulting Ruff-driven type-hint modernizations across the codebase.

Changes:

  • Modernize type annotations to Python 3.10+ syntax (PEP 604 unions, PEP 585 built-in generics) and clean up related typing imports.
  • Remove the hardcoded Ruff target-version so Ruff infers it from requires-python in pyproject.toml.

Reviewed changes

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

Show a summary per file
File Description
src/labelle/lib/utils.py Switch typing imports/annotations to collections.abc and built-in generics.
src/labelle/lib/render_engines/horizontally_combined.py Use collections.abc.Sequence instead of typing.Sequence.
src/labelle/lib/font_config.py Update dict/list/optional types to Python 3.10+ syntax.
src/labelle/lib/config_file.py Update return type to `dict[str, Any]
src/labelle/lib/barcode_writer.py Update list type annotation to list[str].
src/labelle/lib/barcode_to_image.py Update list/tuple/union annotations to Python 3.10+ syntax.
src/labelle/gui/q_render.py Update optional QWidget annotation to `QWidget
src/labelle/gui/q_labels_list.py Update Optional/List annotations to `
src/labelle/gui/q_actions.py Update optional types to `
src/labelle/gui/gui.py Update optional image type to `Image.Image
src/labelle/cli/cli.py Update Typer-exposed parameter annotations to Python 3.10+ syntax and built-in generics.
pyproject.toml Remove Ruff target-version to infer it from project.requires-python.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@maresb maresb merged commit bae2564 into labelle-org:main Jun 1, 2026
6 checks passed
@maresb maresb deleted the chore/ruff-infer-target branch June 1, 2026 16:41
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.

2 participants