Skip to content

Use Python 3.11 features now that 3.10 is dropped #331

Open

Description

@JuroOravec

Part of #177. When Python 3.10 support is dropped (requires-python >= 3.11), the code can use what 3.11 added. This issue tracks a review of where that makes the code simpler or more correct.

What to look for

  • Standard library instead of backports and workarounds
    • tomllib instead of a tomli fallback.
    • typing.Self, Never, LiteralString, assert_never, reveal_type, Required/NotRequired, dataclass_transform, TypeVarTuple/Unpack from typing instead of typing_extensions. About 49 imports use typing_extensions today. Keep it only for names that need 3.12+, and drop the dependency where nothing is left.
    • enum.StrEnum where a str, Enum mix-in is used.
    • datetime.UTC instead of timezone.utc.
  • Error handling
    • BaseException.add_note() for adding context to a re-raised error, where code builds a new message by hand today.
    • ExceptionGroup / except* where several errors are collected and reported together.
  • Async
    • asyncio.TaskGroup and asyncio.timeout() instead of gather plus cancellation by hand, or wait_for.
  • Small helpers
    • contextlib.chdir, operator.call, and hashlib.file_digest, where they fit.
  • Tooling
    • Set ruff's target-version to py311 (or let it follow requires-python) and apply the UP fixes it then reports.
    • Check mypy's python_version.
    • Check whether the Rust extension's abi3 floor moves to py311 (done with the PyO3 upgrade or the 3.10 drop).

How

One focused PR per area. Ruff's automatic fixes can go in a single PR. Behaviour stays the same; any public type hint that changes (for example Self) gets a changelog line only if users could see it.

Activity

  1. added
    next-sprint
    on Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    next-sprint

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions