Repository navigation
mypy: TransportProtocol.undefined types as int, so four base-template defaults disagree with their annotations #770
Description
Activity
- addedbugIssues reporting a defect (set by the bug report template; a default, not an assessment)Issues reporting a defect (set by the bug report template; a default, not an assessment)blockedDeferred pending another issue or decision; see the last comment for what unblocks itDeferred pending another issue or decision; see the last comment for what unblocks it
on Sep 25, 2026 Blocked on #769, which is open and owns
pcapkit/vendor/reg/apptype/apptype.py— theBASEtemplate where the fix for these four errors belongs. #769 is also what unmasks them, by removing the file-wide# mypy: disable-error-code=assignmentpragma, so this issue cannot be actioned before it lands.Unblocks when #769 merges. Note the follow-up recorded in the body:
lint.yml's mypy pin moves 112/38 -> 116/39 at that point.Correction to the site list above — one of the four is misattributed, and it is my error.
apptype.py:2258is not_dispatch. It is the class-level attribute__transport__: 'TransportProtocol' = TransportProtocol.undefined
so it is an attribute assignment rather than a default argument, which is also why its message reads "Incompatible types in assignment" while the other three read "Incompatible default for parameter".
_dispatchhas noprotodefault and contributes nothing here. The correct four sites are__transport__(:2258),__new__(:2282),get(:2371) andget_all(:2429).One further measurement worth recording: the pragma removal is wider than #744 requires. The per-member annotation lives only in the crawler's
TRANSPORTtemplate — the base module has had no members since #754 — so keeping the pragma in the base module while removing it fromTRANSPORTreturns mypy to exactlyFound 112 errors in 38 files (checked 506 source files). That is a live minimal alternative to fixing the inference, measured clean. It does not change the ruling already given (option 1, leave them visible), but it belongs on the record here.- removedblockedDeferred pending another issue or decision; see the last comment for what unblocks itDeferred pending another issue or decision; see the last comment for what unblocks it
on Sep 25, 2026 Unblocked — #769 merged as
83b58ebda, sopcapkit/vendor/reg/apptype/apptype.py(theBASEtemplate, where the fix belongs) is free.The four errors are now live on
main: whole-package mypy is 116 in 39 files, up from 112/38, because #769 removed the file-wide# mypy: disable-error-code=assignment. Two measured notes carried over from the review. The site list in the body is corrected in the comment above —:2258is the class attribute__transport__: 'TransportProtocol' = TransportProtocol.undefined, not_dispatch. And there is a minimal alternative that measures clean: keeping the pragma in the base module alone, while leaving it off the four per-transport modules, restoresFound 112 errors in 38 files (checked 506 source files)exactly — because the per-member annotation only ever lived in theTRANSPORTtemplate. The maintainer ruled (option 1) to leave the errors visible rather than re-suppress, so that alternative is recorded, not recommended.Also still open here:
lint.ymlpins mypy at 112/38 measured at932cb48d1. That pin stays literally true because it names its commit, but the live figure is now 116/39.- addedwipWork in flight - a covering PR is open or an agent is actively on itWork in flight - a covering PR is open or an agent is actively on it
on Sep 25, 2026 - added 3 commits that reference this issue
on Sep 25, 2026 - removedwipWork in flight - a covering PR is open or an agent is actively on itWork in flight - a covering PR is open or an agent is actively on it
on Sep 25, 2026 - added 9 commits that reference this issue
on Sep 28, 2026
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsDone
Describe the bug
Four
[assignment]errors inpcapkit/const/reg/apptype/apptype.py's base-template code, every oneabout
TransportProtocol.undefinedused as a default where aTransportProtocolis annotated. Theywere masked by a file-wide
# mypy: disable-error-code=assignmentpragma until #769 removed it.Reproduction
Whole-package: 112 errors in 38 files → 116 in 39.
Expected behavior
TransportProtocol.undefinedshould type asTransportProtocol, so the four defaults agree withtheir annotations and no suppression is needed.
Additional context
Root cause isolated:
undefined = 0is a bare int literal, so mypy infers its attribute type asint, whiletcp/udp/sctp/dccpareauto()-valued and infer asAny— which is why onlyundefinedtrips it. mypy has noaenumplugin, so the class is treated as a plain class ratherthan an enum. Pre-existing and independent of #769: stripping only the pragma on unmodified
mainreproduces all four, and none of the ~12,391 per-member lines contributes one.The four sites are
__new__,_dispatch,getandget_all; the fix belongs in theBASEtemplate in
pcapkit/vendor/reg/apptype/apptype.py, not in the generated file. Whether it isachievable without an
aenumstub is not established.Not urgent — mypy is advisory in CI (
continue-on-error: trueinlint.yml).One follow-up this creates.
lint.yml's header pins mypy at112 errors / 38 filesmeasured at932cb48d1(#753, #761). That pin stays honest because it names its commit, but once #769 mergesthe current figure is 116/39. Either re-pin it or note the delta here, whichever the maintainer
prefers — flagging it so the two PRs do not quietly leave each other stale.