You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(engines): type the third-party engine packages with local stubs and a per-engine _expkg type #1878
The engines' handle on their third-party package, _expkg, is ModuleType after #1870, so mypy sees every call through it as Any. Per the owner's request on #1870, give each engine real typing.
Current state (mypy 2.3.1, the repo's mypy.ini with ignore_missing_imports = True):
scapy ships py.typed.
dpkt and pyshark are untyped.
pcap (pypcap and pcap-ct) and pcapfile are untyped and are not in the test or docs environments.
Proposed:
Local .pyi stubs, covering only the APIs and data types pcapkit uses, for dpkt, pyshark, pcap and pcapfile. Put them under one stub directory registered via mypy_path, and keep them out of the wheel and sdist.
A per-engine type for _expkg. mypy rejects a module as a type, so use a Protocol per engine, in a TYPE_CHECKING block, describing the attributes the engine reads. The runtime stays lazy-import as it is.
mypy on pcapkit/foundation/engines/ and pcapkit/toolkit/ must report no new errors, and calls through _expkg must type-check against the stubs. A test should pin that each engine's _expkg annotation is its own type and not ModuleType.
Builds on #1870, which removed the class-level engine imports.
A worker is on this. It is stacked on #1870 (branch docs/1857-class-guard-annotations), which moves the engines to _expkg: ModuleType and is what this builds on.
Activity
JarryShaw commentedon Oct 17, 2026
A worker is on this. It is stacked on #1870 (branch
docs/1857-class-guard-annotations), which moves the engines to_expkg: ModuleTypeand is what this builds on.feat(engines): type the third-party engine packages with local stubs (#…
test(project): keep the #1851 and #1878 tests green on the KTLO legs (#…