Skip to content

fix(const): AppType.get takes EnumLookup.get's default and raises EnumValueError (#2545) - #2568

Merged
JarryShaw merged 1 commit into
mainfrom
fix/2545-apptype-get-default
Nov 1, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
fix/2545-apptype-get-default

Conversation

@JarryShaw

Copy link
Copy Markdown
Owner

What is the purpose of your pull request?

  • fix — corrects a defect
  • feat — adds a feature
  • perf — changes performance, not behaviour
  • refactor — changes neither behaviour nor performance
  • test — tests only
  • docs — documentation only
  • ci — workflows or build tooling
  • release — bumps the version or rolls up a distribution
  • chore — anything else
  • const — regenerates constant or registry tables, members keeping their numeric values

Description of your pull request and other information

Closes #2545.

  • Fixed in the vendor template (BASE in pcapkit.vendor.reg.apptype.apptype) and regenerated. The generated diff touches only AppType.get and one sentence of TransportProtocol.get's docstring.
  • AppType.get(key, default=NO_DEFAULT, *, proto=...) honours the base contract, so the type: ignore[override]/arguments-differ pair is gone. As in the base and TransportProtocol.get, default is a member's value, looked up in _value2member_map_, and never mints.
  • A miss raises a quiet EnumValueError, with an unchanged message, where it raised a builtin ValueError. except ValueError still catches it.
  • Left as is: get_all and _dispatch still raise a builtin ValueError for a non-port key. That is a possible follow-up.

…mValueError (#2545)

- AppType.get, in the BASE template of pcapkit.vendor.reg.apptype.apptype,
  takes `default` positionally after `key`, resolved as EnumLookup.get
  resolves its own (through `_value2member_map_`, never minting), in the
  registry the key was dispatched to; the `# type: ignore[override]` /
  `arguments-differ` pair is gone.
- A miss with no usable default raises a quiet EnumValueError with the
  message it raised before, in place of a builtin ValueError.
- pcapkit.const.reg.apptype.apptype regenerated with `pcapkit-vendor
  reg.apptype`; only the two `get` methods change, the per-transport
  modules not at all.
- reg.rst notes the change; the #2048 template-agreement test anchors on the
  new signature; tests/const/test_const_apptype_get_default_2545_unit.py
  pins the two-argument call, the fallback and each miss.
@JarryShaw JarryShaw added fix Pull requests that fix a defect (fix: subject prefix) review: good-to-go Cross-review at the current head says ready; CI state is separate labels Nov 1, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Cross-review (Sonnet) at d641a49dd: GOOD TO GO. Re-running the vendor command leaves the committed const files byte-identical. The diff stays inside AppType.get, and the tcp/udp/sctp/dccp modules are untouched. mypy --warn-unused-ignores is clean. The two-argument calls that raised TypeError on main now honour default, and a miss raises EnumValueError, which is still a ValueError. The new tests fail on main.

@JarryShaw JarryShaw moved this to In review in PyPCAPKit Nov 1, 2026
@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Coverage: 93.95% (unit tier, Python 3.15, d641a49dd, Unit Tests run success)

Package Statements Missed Branches Partial Cover
pcapkit (top level) 104 4 20 2 95.16%
pcapkit/const 20093 144 2712 125 98.78%
pcapkit/corekit 2605 74 818 37 96.52%
pcapkit/dumpkit 281 3 100 3 98.43%
pcapkit/foundation 3194 27 1112 31 98.65%
pcapkit/interface 138 4 52 3 96.32%
pcapkit/protocols 19906 213 5236 207 98.32%
pcapkit/toolkit 924 36 334 10 95.55%
pcapkit/utilities 502 7 144 5 98.14%
pcapkit/vendor 5009 2222 1148 182 52.31%

Per-file detail: the coverage-html artifact of this run.

@JarryShaw
JarryShaw merged commit 1545899 into main Nov 1, 2026
67 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in PyPCAPKit Nov 1, 2026
@JarryShaw
JarryShaw deleted the fix/2545-apptype-get-default branch November 1, 2026 16:06
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Nov 1, 2026
JarryShaw added a commit that referenced this pull request Nov 1, 2026
- Added: one's-complement checksum verification and computation (#2543),
  and the IPX and SCTP registration wrappers (#2521).
- Folded into unreleased entries: LinuxSLL/FRAD/Netlink registries (#2527),
  the IGMP class names (#2542), TLS record chaining and the SSLv2 trial's
  warnings (#2537), DTLS reassembly via Extractor and toolkit (#2528), and
  IP_Pseudo's walk at any depth (#2543). ICMP drops its stale checksum line.
- Breaking: make() checksums, DRARP's module (#2540), IPv6 overlapping
  fragments (#2569), TCP_GAP_LIMIT replacing TCP.__window__ (#2579), and
  Extractor/extract's positional dtls (#2528).
- Changed: member order (#2490), conventions (#2542, #2521, #2570), CI -n
  logical (#2572). Fixed: AppType.get (#2568), trial warnings (#2519, #2577).
- CHANGELOG.md regenerated; util/changelog_md.py --check passes.
@github-actions github-actions Bot added this to the PyPCAPKit v1.6 milestone Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Pull requests that fix a defect (fix: subject prefix)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

fix(const): AppType.get lacks EnumLookup.get's default parameter and raises builtin ValueError on a miss

1 participant