Skip to content

Align the layer sub-package exports with the top-level package - #113

Merged
EONRaider merged 1 commit into
masterfrom
claude/decoder-depth-polish-8m54to
Sep 1, 2026
Merged

Align the layer sub-package exports with the top-level package#113
EONRaider merged 1 commit into
masterfrom
claude/decoder-depth-polish-8m54to

Conversation

@EONRaider

Copy link
Copy Markdown
Owner

Summary

Closes#80.

Each layer's __init__ carried a subset of what the top-level package
re-exports, so from netprotocols.layer7 import DHCP failed while
from netprotocols import DHCP worked. The asymmetry only bites people
who import by layer, and is invisible from the top.

What's included

  • src/netprotocols/layer3/__init__.py — adds GRE, IPv4Option,
    IPv6Option, NDPOption, IGMPv3GroupRecord.
  • src/netprotocols/layer4/__init__.py — adds TCPOption.
  • src/netprotocols/layer7/__init__.py — adds DHCP, DNSOverTCP,
    DNSResourceRecord.
  • tests/test_exports.py — 33 parametrized cases keeping the two sets
    in agreement.
  • CHANGELOG.md — entries under ## [Unreleased].

layer2 was already complete. Purely additive: no name changed meaning,
and every added object is the same object the top level exposes (the
test asserts identity, not just presence).

One extra find

layer4 was missing TCPOption, which the issue did not mention. It
turned up because the test derives the expected set from each object's
__module__ rather than working from the reported list — the same
approach that will catch the next one.

Verification

  • uv run ruff check and uv run ruff format --check are clean
  • uv run mypy is clean (strict)
  • uv run pytest passes — 735 tests, 33 new; coverage 99.79%, above
    the gate Enforce the coverage level already achieved #79 just added
  • CHANGELOG.md has an entry under ## [Unreleased]

The imports named in the issue, which previously raised ImportError:

fromnetprotocols.layer7importDHCP, DNSOverTCP, DNSResourceRecordfromnetprotocols.layer3importGRE, NDPOption, IGMPv3GroupRecord, IPv4Option, IPv6Optionfromnetprotocols.layer4importTCPOption

And the test was checked against a regression — removing DHCP from
layer7's __all__ fails
test_name_is_exported_by_its_layer[layer7-DHCP] rather than passing
quietly.

Notes

test_every_layer_contributes_something exists to guard the derivation
itself: the parametrized cases are generated by inspecting __module__,
so if that inspection ever broke, the list would empty and every case
above it would vacuously pass. That test fails instead.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QJnVMNGwTRDktC4rkABtgt


Generated by Claude Code

Each layer's __init__ carried a subset of what the top-level package
re-exports, so "from netprotocols.layer7 import DHCP" failed while
"from netprotocols import DHCP" worked -- an asymmetry that only bites
people who import by layer, and is invisible from the top.
layer3 was missing GRE, IPv4Option, IPv6Option, NDPOption and
IGMPv3GroupRecord; layer7 exported only DNS, omitting DHCP, DNSOverTCP
and DNSResourceRecord. layer4 was missing TCPOption, which the issue did
not mention -- the same defect, found by deriving the expected set
rather than working from the reported list.
tests/test_exports.py now derives that expectation from each object's
__module__, so a protocol added to the top level but forgotten in its
layer fails the suite. It also checks the converse (no layer exports a
name the top level lacks) and guards its own derivation, so a broken
__module__ inspection cannot make the parametrized cases vacuously pass.
Closes#80
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QJnVMNGwTRDktC4rkABtgt
@EONRaider
EONRaider merged commit d7e9fc4 into masterSep 1, 2026
6 checks passed
@EONRaiderEONRaider mentioned this pull request Sep 4, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Align the layer sub-package exports with the top-level package

2 participants

@EONRaider@claude