Skip to content

Modernize typing and require Python 3.10+#254

Open
bryanforbes wants to merge 1 commit into
gvalkov:mainfrom
bryanforbes:feat/improve-typing
Open

Modernize typing and require Python 3.10+#254
bryanforbes wants to merge 1 commit into
gvalkov:mainfrom
bryanforbes:feat/improve-typing

Conversation

@bryanforbes
Copy link
Copy Markdown

Drop Python 3.9 support and overhaul typing throughout the package.

  • Bump minimum Python to 3.10 in pyproject.toml and CI matrix.
  • Add from __future__ import annotations across the package.
  • Replace Union/Optional/Dict/List/Tuple with PEP 604/585 syntax.
  • Add precise @overload sets for capabilities, _capabilities, input_props, leds, active_keys, and resolve_ecodes.
  • Introduce _Capabilities, _AbsInfoCapabilities, and _VerboseAbsInfoCapabilities for richer return types on capabilities().
  • Generate _CapabilitiesKeys, _CapabilitiesAbsKeys, and verbose variants from genecodes_py.py and emit _ecodes.pyi from genecodes_c.py during build.
  • Add .pyi stubs for the _input and _uinput C extensions.
  • Type UInput.from_device kwargs with TypedDict + Unpack.
  • Type the need_write decorator with Concatenate/ParamSpec.
  • Add HasEvent protocol and is_has_event type guard for write_event.
  • Annotate ctypes.Structure fields in ff.py.
  • Enable ruff UP and TC rule sets and replace %/.format() with f-strings.

Drop Python 3.9 support and overhaul typing throughout the package.

- Bump minimum Python to 3.10 in `pyproject.toml` and CI matrix.
- Add `from __future__ import annotations` across the package.
- Replace `Union`/`Optional`/`Dict`/`List`/`Tuple` with PEP 604/585
  syntax.
- Add precise `@overload` sets for `capabilities`, `_capabilities`,
  `input_props`, `leds`, `active_keys`, and `resolve_ecodes`.
- Introduce `_Capabilities`, `_AbsInfoCapabilities`, and
  `_VerboseAbsInfoCapabilities` for richer return types on
  `capabilities()`.
- Generate `_CapabilitiesKeys`, `_CapabilitiesAbsKeys`, and verbose
  variants from `genecodes_py.py` and emit `_ecodes.pyi` from
  `genecodes_c.py` during build.
- Add `.pyi` stubs for the `_input` and `_uinput` C extensions.
- Type `UInput.from_device` kwargs with `TypedDict` + `Unpack`.
- Type the `need_write` decorator with `Concatenate`/`ParamSpec`.
- Add `HasEvent` protocol and `is_has_event` type guard for
  `write_event`.
- Annotate `ctypes.Structure` fields in `ff.py`.
- Enable ruff `UP` and `TC` rule sets and replace `%`/`.format()`
  with f-strings.
@bryanforbes bryanforbes force-pushed the feat/improve-typing branch from 9fc042e to 6216cdb Compare May 25, 2026 01:03
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