Modernize typing and require Python 3.10+#254
Open
bryanforbes wants to merge 1 commit into
Open
Conversation
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.
9fc042e to
6216cdb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Drop Python 3.9 support and overhaul typing throughout the package.
pyproject.tomland CI matrix.from __future__ import annotationsacross the package.Union/Optional/Dict/List/Tuplewith PEP 604/585 syntax.@overloadsets forcapabilities,_capabilities,input_props,leds,active_keys, andresolve_ecodes._Capabilities,_AbsInfoCapabilities, and_VerboseAbsInfoCapabilitiesfor richer return types oncapabilities()._CapabilitiesKeys,_CapabilitiesAbsKeys, and verbose variants fromgenecodes_py.pyand emit_ecodes.pyifromgenecodes_c.pyduring build..pyistubs for the_inputand_uinputC extensions.UInput.from_devicekwargs withTypedDict+Unpack.need_writedecorator withConcatenate/ParamSpec.HasEventprotocol andis_has_eventtype guard forwrite_event.ctypes.Structurefields inff.py.UPandTCrule sets and replace%/.format()with f-strings.