Repository navigation
Typed - #160
Typed#160markus-becker-tridonic-com wants to merge 1 commit into
Conversation
42fd4da to
1ae2754
Compare
Ship PEP 561 py.typed markers for every public subpackage (dali, device, driver, gear, memory) and include them in the built distribution via MANIFEST.in and include_package_data, so downstream consumers' type checkers follow python-dali as a typed dependency. Annotate the public signatures the consumers call: Response/Command in command.py, the address constructors, the gear/device command bases, the commissioning and query sequences, memory bank read_all, and the typed exceptions. Signatures only; no behavior change. Add `from __future__ import annotations` where PEP 604 unions require it on the 3.7 floor, and fix the malformed dict[(int, int), int] annotation. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
07a4e9c to
78bcee9
Compare
|
I've rebased this again on current master (the "Unify driver send()/run_sequence() and add a transmit priority" commit) so I can read the diff more easily, and run tests. Notes:
I think I'm going to try to add typing to the whole library, not just the public interface; that way, type checking can be part of the test suite. |
|
Work in progress on typing for the whole library is in the "typing" branch; currently dali/gear/ and dali/device/ (and implicitly all the python files directly in dali/) are passing mypy --strict and I'm working on dali/memory/ |
Any preference on how to handle the dependencies pyusb, pymodbus?
|
|
They won't be an issue once drivers are removed from python-dali! Fully typing the drivers can be a separate project. |
Summary
Make python-dali a typed (PEP 561) package so downstream consumers' type
checkers follow it as a typed dependency. Ships
py.typedmarkers for everypublic subpackage and annotates the public signatures consumers call.
What's included (top commit)
py.typedmarkers fordali,dali/device,dali/driver,dali/gear,dali/memory, included in the built distribution viaMANIFEST.in+include_package_data.Response/Command(command.py), theaddress constructors, the gear/device command bases, the commissioning and
query sequences, memory-bank
read_all, and the typed exceptions.from __future__ import annotationswhere PEP 604 unions require it on the3.7 floor; fixes the malformed
dict[(int, int), int]→dict[tuple[int, int], int]annotation.This branch is stacked on the full integration feature set (serialx
migration, part 306, DT8 colour sequences, control-device commissioning, DT1).
The typing change is the top commit (
574b461c13cb3606e14aa585f9d4bbf27805ede2); againstmasterthe PRshows ~20 commits because the annotations cover symbols introduced across those
branches and cannot stand alone. Review the top commit, or retarget the PR base
to the appropriate branch once the underlying stack has landed.
Testing
mypywith 0 errors against a non-editable wheel of this branch, andpy.typedis present in the wheelRECORD.