Skip to content

refactor(protocols): order application protocol members - #2491

Merged
JarryShaw merged 2 commits into
mainfrom
refactor/2490-member-order-application
Oct 31, 2026
Merged

JarryShaw merged 2 commits into
mainfrom
refactor/2490-member-order-application

Conversation

@JarryShaw

Copy link
Copy Markdown
Owner

Please follow the guide below

  • You will be asked some questions, please read them carefully and answer honestly

  • Put an x into all the boxes [ ] relevant to your pull request (like that [x])

  • Use Preview tab to see how your pull request will actually look like

  • Searched for similar pull requests

  • Followed the coding style (make pylint, make mypy, make isort)

  • make test passes, and a test case covers the change

  • Added a changelog entry under docs/source/changelog/ and regenerated CHANGELOG.md, if the change is user-visible

What is the purpose of your pull request?

Tick the commit type your subject line carries.

  • 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

  Member-order reorder for the application protocol group: Application, HTTP v1 and v2, OSPF, SSL, and the HTTP v2 Settings data model. Public members now sit ahead of dunders, _make_data leads the utilities, and each _read_* precedes the _make_* helpers. Moves only, plus one section banner added to Application; no body, name or behaviour changed.

Checked: examples/generators/make_samples.py runs against this tree; coverage run -m pytest tests/protocols/application/ gives 340 passed; isort --check -l100 -p pcapkit is clean on the changed files. The full suite and pylint/mypy were not run.

Refs #2490

Move public members ahead of dunders and read helpers ahead of make helpers
in Application, HTTP v1/v2, OSPF, SSL and the HTTP v2 Settings data model.
Pure reorder: no bodies, names or behaviour changed. Refs #2490
@JarryShaw JarryShaw added refactor Restructuring for its own sake — neither a fix nor a new capability (refactor: prefix) review: running A cross-review is in flight against the current head - no verdict yet labels Oct 31, 2026
@JarryShaw JarryShaw moved this to In review in PyPCAPKit Oct 31, 2026
@JarryShaw JarryShaw added review: pending No verdict for the current head - never reviewed, or the head moved since the last one and removed review: running A cross-review is in flight against the current head - no verdict yet labels Oct 31, 2026
@github-actions

github-actions Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Coverage: 94.50% (unit tier, Python 3.15, fe6ea7f7d, Unit Tests run success)

Package Statements Missed Branches Partial Cover
pcapkit (top level) 104 4 20 2 95.16%
pcapkit/const 19677 133 2628 120 98.85%
pcapkit/corekit 2605 74 818 37 96.52%
pcapkit/dumpkit 281 3 100 3 98.43%
pcapkit/foundation 3070 24 1072 26 98.79%
pcapkit/interface 138 4 52 3 96.32%
pcapkit/protocols 18066 194 4786 180 98.35%
pcapkit/toolkit 924 36 334 10 95.55%
pcapkit/utilities 502 7 144 5 98.14%
pcapkit/vendor 4449 1854 1020 167 55.11%

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

@JarryShaw

Copy link
Copy Markdown
Owner Author

NEEDS CHANGES (Sonnet, b32b8e583). Pure move (AST-equal); 335 tests pass; the 5 failures are generated sample captures missing from the export, also on main.

  • httpv1.py: _check_raw (~L291) precedes _make_data; _split_field_lines (~L413) precedes _read_http_body (~L538). httpv2.py: _make_http_length (~L1067) is used directly by make but sits after the reads; check against the rule.

@JarryShaw JarryShaw added review: needs-changes Cross-review at the current head says changes are required; see the verdict comment and removed review: pending No verdict for the current head - never reviewed, or the head moved since the last one labels Oct 31, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

HTTP's _check_raw is a private method, it still belongs to the Utilities section.

Is this not covered by the convention? Let's fix the doc as well then.

@JarryShaw

Copy link
Copy Markdown
Owner Author

Ruling reconciled: your point is that _check_raw is a private helper, so it belongs in the Utilities section, not before _make_data. The convention already says private helpers go in Utilities after Data models, so this PR is out of line, and the convention doc should say it explicitly. Changes: (1) move _check_raw in httpv1.py (about line 291) into Utilities, and check the other private helpers in httpv1.py and httpv2.py the same way; (2) add a line to docs/source/contributing/conventions/protocol-member-order.rst that every private helper, _check_* included, sits in Utilities. Still open: the NEEDS CHANGES items from the last review. Worker dispatched; push waits for the queue.

- httpv1: move _check_raw out of Methods into Utilities, before
  _read_field_line, since make() calls it.
- httpv1: read _read_http_body before _split_field_lines, the order read()
  first uses them.
- httpv1: keep _read_start_line and _make_start_line together, reader first.
- httpv2: move _make_http_length, called directly by make(), ahead of the
  frame readers in Utilities.

Pure reorder: no bodies, names or behaviour changed. Refs #2490
@JarryShaw JarryShaw added review: pending No verdict for the current head - never reviewed, or the head moved since the last one and removed review: needs-changes Cross-review at the current head says changes are required; see the verdict comment labels Oct 31, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Pushed. The HTTP helpers now sit in Utilities: _check_raw in httpv1.py, and _make_http_length in httpv2.py, with the review-order items applied. The convention doc now says every private helper, including _check_*, sits in Utilities, not before _make_data(). That rule went to main as a docs-only change (c17a0a932), because this branch predates the convention doc. Head is fe6ea7f7d, pending a fresh review.

@JarryShaw

Copy link
Copy Markdown
Owner Author

GOOD TO GO (Sonnet, fe6ea7f7d). Only httpv1.py and httpv2.py changed. Method bodies are identical by AST comparison, and the order matches the convention on main. Convention test: 34 passed, 1 skipped. HTTP tests: 180 passed, 5 failed. The 5 failures are in test_http_runtime.py: the generated sample capture http.pcap is missing from this environment, and they fail the same way on the base. They are not caused by this PR. Merge is yours.

@JarryShaw JarryShaw added review: good-to-go Cross-review at the current head says ready; CI state is separate and removed review: pending No verdict for the current head - never reviewed, or the head moved since the last one labels Oct 31, 2026
@JarryShaw
JarryShaw merged commit 487c91c into main Oct 31, 2026
65 checks passed
@JarryShaw
JarryShaw deleted the refactor/2490-member-order-application branch October 31, 2026 15:18
@github-project-automation github-project-automation Bot moved this from In review to Done in PyPCAPKit Oct 31, 2026
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Oct 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Restructuring for its own sake — neither a fix nor a new capability (refactor: prefix)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant