Repository navigation
feat(engines): type the third-party engine packages with local stubs (#1878) - #1882
Merged
Merged
Conversation
Owner
Author
|
Verdict: GOOD TO GO at
Merge #1870 first: this PR is stacked on it. |
Owner
Author
|
resolve conflicts |
Owner
Author
|
On it. #1870 merged as a squash, so this branch is being rebased onto |
…1878) - Add stubs under typings/ for dpkt 1.9.8, pyshark 0.6, pcap (pypcap 1.3.0 and pcap-ct 1.3.0b3) and pypcapfile 0.12.0, declaring only what pcapkit uses; register them in mypy.ini through mypy_path, and prune them from the sdist. - Annotate each engine's _expkg with a Protocol of its own, in the module-level TYPE_CHECKING block, of what the engine reads; scapy's uses scapy's own types. Runtime is unchanged: no engine package is imported at module load. - Fix what the stubs reveal: DPKT's PCAP reader yields a Decimal timestamp for a nanosecond file, its PCAP-NG option reads and a reassigned local lacked their types, and casts the stubs make redundant are dropped. - Note the stubs in the contributing conventions. - Add a unit test pinning the annotations, that each protocol declares what its engine reads, and that the stubs are registered and cover each import of them. Closes #1878
JarryShaw
force-pushed
the
feat/1878-engine-stubs
branch
from
October 17, 2026 02:19
efdbffa to
053c4f0
Compare
Owner
Author
|
Verdict: GOOD TO GO at
|
Contributor
|
Coverage: 90.05% (unit tier, Python 3.15,
Per-file detail: the |
Merged
4 of 13 tasks
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.
Please follow the guide below
You will be asked some questions, please read them carefully and answer honestly
Put an
xinto all the boxes [ ] relevant to your pull request (like that [x])Use Preview tab to see how your pull request will actually look like
Searched for similar pull requests
Followed the coding style (
make pylint,make mypy,make isort)make testpasses, and a test case covers the change. Narrow runs only, listed below.Added a changelog entry under
docs/source/changelog/and regeneratedCHANGELOG.md, if the change is user-visible: N/A — centralised in docs(changelog): shared 1.5.0 changelog — long-lived, merges last (#610, #616, #617, #618, #620) #657What is the purpose of your pull request?
Tick the commit type your subject line carries.
fix— corrects a defectfeat— adds a featureperf— changes performance, not behaviourrefactor— changes neither behaviour nor performancetest— tests onlydocs— documentation onlyci— workflows or build toolingrelease— bumps the version or rolls up a distributionchore— anything elseStacked on #1870. It contains #1870's commit until that merges, so merge #1870 first. This PR's own commit is
efdbffa95.typings/type the dpkt, pyshark,pcap(pypcap and pcap-ct) and pypcapfile packages, declaring only what pcapkit uses.mypy.iniregisters them throughmypy_path, and they are not in the sdist or wheel._expkgis annotated with its own Protocol in the module-levelTYPE_CHECKINGblock. Scapy's uses scapy's own types. At runtime nothing changes: importing an engine module loads none of the engine packages.Decimaltimestamp for nanosecond files, and its PCAP-NG option reads were missing casts.make mypy's whole-package count drops by two.stubtestis clean for dpkt, pyshark and pypcapfile. For pcap-ct the only report is its extradatalinkargument, which the stub leaves out on purpose so it matches bothpcapdistributions.tests/project/test_engine_stubs_1878_unit.pyfails on docs: let autodoc resolve the HTTP/2 frame and engine class annotations (#1857) #1870's head and passes here. A merge with docs(foundation): restore Extractor._vfunc's annotation (#1839) #1867's branch is clean and adds no mypy errors.Closes #1878