Repository navigation
refactor: remove two unreachable branches, commented-out raises and unused test helpers (#2318) - #2378
Conversation
|
Coverage: 91.58% (unit tier, Python 3.15,
Per-file detail: the |
|
Review: NEEDS CHANGES at Also: the two new test modules violate the #1103 house convention (change-relative "are gone"/"Three guards"/counted-number prose instead of timeless statements), and the PR body's "every case fails on the parent commit" is false for 6 of 14 methods (by design — they pin unchanged behavior). Restoring the guard per the reviewer's recommendation, plus the prose/body corrections. Fix in progress. |
69a9288 to
993f4a2
Compare
|
Amended Restored the |
|
Review: NEEDS CHANGES at
Fix in progress. |
993f4a2 to
0d7b200
Compare
|
Amended All findings across all 3 rounds now addressed. |
|
Review: GOOD TO GO at Two before-merge follow-ups, both reasonable — will do: (1) note the QS deviation on #2318 itself, since closing it via this PR would otherwise leave the issue's "dead" claim unaddressed where the owner ruled on it; (2) add a CALIPSO construction-route test as a backstop, since that route is correctly unreachable today but has no test pinning it. |
…nused test helpers (#2318) Problem: two guards could never run, because something earlier had already raised -- Header.read's FileError on an unknown magic number, which the schema's magic_number_callback beats to it; and _read_opt_calipso's two length guards, which calipso_pad_len beats to it while the option is unpacked. Beside them sat commented-out raise lines next to the warn that replaced them, a repeated pylint: disable=unused-argument, and three names nothing read: dispatch.py's _internet_enum, a FAKE_GH query no caller sends, and GATING. A third candidate, _read_opt_qs's unknown QS function arm, looked unreachable the same way but is not: the unassigned-option dispatch it depends on is by schema class, decided from the func a parse's own registry resolves it against, not from the func held in a directly-constructed schema's flags. A QuickStartRequestOption or QuickStartReportOption built directly with an unassigned func reaches this method's own check regardless, and a parse reaches it too once a caller registers a schema against that func, so it stays, with a Note on each of the three readers explaining why. Fix: the two genuinely unreachable guards are deleted, with the prose that described them corrected -- Header.read documents ProtocolError, and _read_opt_calipso documents what checked the length instead. The three fabricated-schema stanzas that reached the deleted guards by calling a private reader directly are replaced by the real parse paths, which raise as before. Test: tests/protocols/test_dead_branches_2318_unit.py parses what was supposed to reach each deleted branch and pins what happens instead, pins the restored QS guard against both schema kinds across all three protocols through the public construction path and through a parse once a schema is registered against the func, and pins the source as holding no such deleted branch, no commented-out raise beside a warn, and no repeated pragma; tests/project/test_dead_helpers_2318_unit.py pins the rule that made each helper dead. 8 of the 17 test methods across the two files fail on the parent commit; the other 9 pin unchanged behaviour by design.
0d7b200 to
ab96134
Compare
|
Amended Both follow-ups from round 3 now done: the #2318 clarifying comment and this test. |
|
Ready to merge. Review: GOOD TO GO (Sonnet, round 3) at |
Problem: of the 60 pull requests merged in the #2312-#2407 range, only #2334, #2336, #2337, #2340 and #2348 wrote a 1.5.0 changelog entry, and #2398 and #2403 only reworded lines that were already there. Every other user-visible change in the range -- wire-semantics fixes, maker guards, reassembly behaviour, public-API and error-message changes -- went unrecorded, so the entry no longer describes the release. Fix: one entry per user-visible pull request, in each module section's existing style and ordered by the issue it closes. Two pairs share a bullet, since each is the direct follow-up of the other: #2393 with #2401, and #2405 with #2407. The diff on the entry file is purely additive. Internal-only work is left out deliberately: dependency and action bumps (#2387 to #2391), test-only and docs-prose passes (#2333, #2376, #2379, #2380, #2402), the unreachable-branch removal (#2378), and the #: comment marker the HIP Group and Packet crawlers now write (#2381). That last one renders nothing either way: the marker lands inside the generated _missing_ body, conf.py's exclude-members drops _missing_ from autodoc, and a comment in a method body is not an attribute comment to begin with. #2392 and #2403 are recorded together, under Added rather than Fixed, for the declarations they introduce: __proto_key__ on the seven classes owning a __proto__ registry (#2392), __proto_dest__ on the four enum registries and Vendor.PROTO_DEST to generate it (#2403). Both PRs added the autodoc entries, so both are rendered public attributes. #2392's rejection-message change is deliberately not recorded as a fix: the bare "code must be ..." text it prefixed came from _check_code, which #2193 introduced and which is in no release tag -- absent at v1.5.0b14 -- so no released version ever emitted it. #2403 is no longer skipped as internal because it reworded an existing bullet to name __proto_dest__ while nothing credited the attribute's introduction. Four claims are corrected against the source rather than carried over: FTP_DATA shipped in pcapkit/protocols/application/ftp.py from 1.0.0, not 1.4.0 (class FTP_DATA(Raw) is there at v1.0.0); #2365's pre-fix fallback read cmmd.value, so a .value-carrying object was accepted unchecked rather than raising; #2399 left the dpkt adapter and the adapters' ModuleNotFound raises alone, so it claims no universal prefix; and #2397's old tail did name the version it got, so the entry quotes it and gains the :issue:`2302` it was missing. #2370's "a Section Header Block ... still fails" sentence is dropped: #2369 settles the byte order first, and an SHB built from raw octets with ctx=None now rebuilds byte-exact in both byte orders. CHANGELOG.md is regenerated with util/changelog_md.py. Test: tests/project/ in full, 0 failures, including test_changelog_md.py's in-step and supported-subset checks; util/changelog_md.py --check reports the two files in step; the entry parses under docutils with no structural warning.
Problem: of the 60 pull requests merged in the #2312-#2407 range, only #2334, #2336, #2337, #2340 and #2348 wrote a 1.5.0 changelog entry, and #2398 and #2403 only reworded lines that were already there. Every other user-visible change in the range -- wire-semantics fixes, maker guards, reassembly behaviour, public-API and error-message changes -- went unrecorded, so the entry no longer describes the release. Fix: one entry per user-visible pull request, in each module section's existing style and ordered by the issue it closes. Three pairs share a bullet, since each is the direct follow-up or counterpart of the other: #2393 with #2401, #2405 with #2407, and #2392 with #2403. The diff on the entry file is purely additive. Internal-only work is left out deliberately: dependency and action bumps (#2387 to #2391), test-only and docs-prose passes (#2333, #2376, #2379, #2380, #2402), the unreachable-branch removal (#2378), and the #: comment marker the HIP Group and Packet crawlers now write (#2381). That last one renders nothing either way: the marker lands inside the generated _missing_ body, conf.py's exclude-members drops _missing_ from autodoc, and a comment in a method body is not an attribute comment to begin with. #2392 and #2403 are recorded together, under Added rather than Fixed, for the declarations they introduce: __proto_key__ on each class owning a __proto__ registry (#2392), __proto_dest__ on the enum registries and Vendor.PROTO_DEST to generate it (#2403). The bullet names those classes and registries rather than counting them, per the no-counted-numbers rule for the unreleased entry. Both PRs added the autodoc entries, so both are rendered public attributes. #2392's rejection-message change is deliberately not recorded as a fix: the bare "code must be ..." text it prefixed came from _check_code, which #2193 introduced and which is in no release tag -- absent at v1.5.0b14 -- so no released version ever emitted it. #2403 is no longer skipped as internal because it reworded an existing bullet to name __proto_dest__ while nothing credited the attribute's introduction. Four claims are corrected against the source rather than carried over: FTP_DATA shipped in pcapkit/protocols/application/ftp.py from 1.0.0, not 1.4.0 (class FTP_DATA(Raw) is there at v1.0.0); #2365's pre-fix fallback read cmmd.value, so a .value-carrying object was accepted unchecked rather than raising; #2399 left the dpkt adapter and the adapters' ModuleNotFound raises alone, so it claims no universal prefix; and #2397's old tail did name the version it got, so the entry quotes it and gains the :issue:`2302` it was missing. #2370's "a Section Header Block ... still fails" sentence is dropped: #2369 settles the byte order first, and an SHB built from raw octets with ctx=None now rebuilds byte-exact in both byte orders. CHANGELOG.md is regenerated with util/changelog_md.py. Test: tests/project/ in full, 0 failures, including test_changelog_md.py's in-step and supported-subset checks; util/changelog_md.py --check reports the two files in step; the entry parses under docutils with no structural warning.
Problem: of the 60 pull requests merged in the #2312-#2407 range, only #2334, #2336, #2337, #2340 and #2348 wrote a 1.5.0 changelog entry, and #2398 and #2403 only reworded lines that were already there. Every other user-visible change in the range -- wire-semantics fixes, maker guards, reassembly behaviour, public-API and error-message changes -- went unrecorded, so the entry no longer describes the release. Fix: one entry per user-visible pull request, in each module section's existing style and ordered by the issue it closes. Three pairs share a bullet, since each is the direct follow-up or counterpart of the other: #2393 with #2401, #2405 with #2407, and #2392 with #2403. The diff on the entry file is purely additive. Internal-only work is left out deliberately: dependency and action bumps (#2387 to #2391), test-only and docs-prose passes (#2333, #2376, #2379, #2380, #2402), the unreachable-branch removal (#2378), and the #: comment marker the HIP Group and Packet crawlers now write (#2381). That last one renders nothing either way: the marker lands inside the generated _missing_ body, conf.py's exclude-members drops _missing_ from autodoc, and a comment in a method body is not an attribute comment to begin with. #2392 and #2403 are recorded together, under Added rather than Fixed, for the declarations they introduce: __proto_key__ on each class owning a __proto__ registry (#2392), __proto_dest__ on the enum registries and Vendor.PROTO_DEST to generate it (#2403). The bullet names those classes and registries rather than counting them, per the no-counted-numbers rule for the unreleased entry. Both PRs added the autodoc entries, so both are rendered public attributes. #2392's rejection-message change is deliberately not recorded as a fix: the bare "code must be ..." text it prefixed came from _check_code, which #2193 introduced and which is in no release tag -- absent at v1.5.0b14 -- so no released version ever emitted it. #2403 is no longer skipped as internal because it reworded an existing bullet to name __proto_dest__ while nothing credited the attribute's introduction. Four claims are corrected against the source rather than carried over: FTP_DATA shipped in pcapkit/protocols/application/ftp.py from 1.0.0, not 1.4.0 (class FTP_DATA(Raw) is there at v1.0.0); #2365's pre-fix fallback read cmmd.value, so a .value-carrying object was accepted unchecked rather than raising; #2399 left the dpkt adapter and the adapters' ModuleNotFound raises alone, so it claims no universal prefix; and #2397's old tail did name the version it got, so the entry quotes it and gains the :issue:`2302` it was missing. #2370's "a Section Header Block ... still fails" sentence is dropped: #2369 settles the byte order first, and an SHB built from raw octets with ctx=None now rebuilds byte-exact in both byte orders. CHANGELOG.md is regenerated with util/changelog_md.py. Test: tests/project/ in full, 0 failures, including test_changelog_md.py's in-step and supported-subset checks; util/changelog_md.py --check reports the two files in step; the entry parses under docutils with no structural warning.
make testpasses, and a test case covers the changeWhat is the purpose of your pull request?
refactor — code refactoringDescription
Closes #2318.
Header.read'sFileErroron an unknown magic number, which the schema'smagic_number_callbackbeats to it; and_read_opt_calipso's two length guards, whichcalipso_pad_lenbeats to it while the option is unpacked. Beside them sat commented-outraiselines next to thewarnthat replaced them, a repeatedpylint: disable=unused-argument, and three names nothing read:dispatch.py's_internet_enum, aFAKE_GHquery no caller sends, andGATING._read_opt_qs's unknown QS function arm, is NOT dead — the unassigned-option dispatch it depends on is by schema class, decided from the func a parse's own registry resolves it against, not from the func held in a directly-constructed schema's flags. AQuickStartRequestOptionorQuickStartReportOptionbuilt directly with an unassignedfuncreaches this method's own check regardless, and a parse reaches it too once a caller registers a schema against that func, so it stays, with aNoteon each of the three readers explaining why.Header.readdocumentsProtocolError, and_read_opt_calipsodocuments what checked the length instead. The three fabricated-schema stanzas that reached the deleted guards by calling a private reader directly are replaced by the real parse paths, which raise as before.tests/protocols/test_dead_branches_2318_unit.pyparses what was supposed to reach each deleted branch and pins what happens instead, pins the restored QS guard against both schema kinds across all three protocols through the public construction path and through a parse once a schema is registered against the func, and pins the source as holding no such deleted branch, no commented-outraisebeside awarn, and no repeated pragma;tests/project/test_dead_helpers_2318_unit.pypins the rule that made each helper dead. 8 of the 17 test methods across the two files fail on the parent commit; the other 9 pin unchanged behaviour by design.