Describe the bug
Four [assignment] errors in pcapkit/const/reg/apptype/apptype.py's base-template code, every one
about TransportProtocol.undefined used as a default where a TransportProtocol is annotated. They
were masked by a file-wide # mypy: disable-error-code=assignment pragma until #769 removed it.
Reproduction
$ mypy --follow-imports=silent --ignore-missing-imports --show-column-numbers --show-error-codes \
pcapkit/const/reg/apptype/apptype.py # with the pragma
Success: no issues found in 1 source file
$ # same command, pragma removed
:2258:42: error: Incompatible types in assignment (expression has type "int", variable has type "TransportProtocol") [assignment]
:2282:46: error: Incompatible default for parameter "proto" (default has type "int", parameter has type "TransportProtocol") [assignment]
:2371:48: error: Incompatible default for parameter "proto" (default has type "int", parameter has type "TransportProtocol | str") [assignment]
:2429:52: error: Incompatible default for parameter "proto" (default has type "int", parameter has type "TransportProtocol | str") [assignment]
Found 4 errors in 1 file (checked 1 source file)
Whole-package: 112 errors in 38 files → 116 in 39.
Expected behavior
TransportProtocol.undefined should type as TransportProtocol, so the four defaults agree with
their annotations and no suppression is needed.
Additional context
Root cause isolated: undefined = 0 is a bare int literal, so mypy infers its attribute type as
int, while tcp/udp/sctp/dccp are auto()-valued and infer as Any — which is why only
undefined trips it. mypy has no aenum plugin, so the class is treated as a plain class rather
than an enum. Pre-existing and independent of #769: stripping only the pragma on unmodified
main reproduces all four, and none of the ~12,391 per-member lines contributes one.
The four sites are __new__, _dispatch, get and get_all; the fix belongs in the BASE
template in pcapkit/vendor/reg/apptype/apptype.py, not in the generated file. Whether it is
achievable without an aenum stub is not established.
Not urgent — mypy is advisory in CI (continue-on-error: true in lint.yml).
One follow-up this creates. lint.yml's header pins mypy at 112 errors / 38 files measured at
932cb48d1 (#753, #761). That pin stays honest because it names its commit, but once #769 merges
the 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.
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.