Repository navigation
refactor(const): f-string the last three %-formatted __repr__ methods (#804) - #817
Conversation
|
Both of the author's corrections to #804's text are right, and both were my errors. Verified: 1. My "nothing in So this PR earns the disable for its pair, which is the honest claim, and eight other files still carry it. Filing that remainder separately rather than widening this PR. 2. My table's Inside a The load-bearing test find, and it was handled the right way. Verification I accept as done: template render-and-diff byte-identical with diffs of exactly 6 and 4 lines (the two Its Also correct and worth crediting: the Cross-review dispatching now, on a model other than the one that authored this. |
|
Cross-review verdict: GOOD TO GO (sonnet; author was haiku). Every item confirmed, several exactly. No unprompted findings above informational. The test flip is strictly stricter, which was the thing to check — verified by me: The two modules moved from "must keep the disable" to "must not have it", joining the other two — so the guard now covers 4 modules under the stronger assertion instead of 2 under each. Nothing in the +269/−19 touches any other existing assertion: the diff is exactly 3 hunks, two of them pure additions. The tests genuinely ran, and the reviewer proved the gate distinguishes ran from skipped — the check I care most about here, since both tests are Pylint confirmed character for character: 16 findings on both sides, zero Render-and-diff re-derived independently (its own script, not the test's assertions): 6 changed lines for Fail-before exactly: Proportionality judged, and I agree with the reasoning: +269 test lines for a 14-line source change is proportionate because each new test closes a failure mode this file family has actually suffered — a quote-blind grep (now a self-tested detector), a half-applied template/const edit (render-and-diff), an assumed-but-unverified output equivalence (#796's own mistake, now proven member by member), and a silently-skipped render test. One informational, pre-existing on both sides:
Flipping to |
|
The four red legs are NOT this PR's fault — they are inherited from One defect, four legs. This PR is based on The verdict on this change stands at This is my error, and worth stating plainly: I cleared #813 as |
|
CI tests are failing (seems like failing on main branch as well, can be fixed with a direct push there). |
|
Ruling recorded, in your words:
Confirmed, and it is now half done by your own merge: #820 landed as I did not take the direct push, deliberately. The one remaining red on If you would rather I push it straight to |
…#804) * pcapkit/const/ftp/command.py:40,119 and pcapkit/const/http/method.py:42 formatted their __repr__ with %, which is what kept `# pylint: disable=consider-using-f-string` alive in both files. Converted to f-strings, and the disable dropped from both. * Made the same edit in pcapkit/vendor/{ftp/command,http/method}.py's LINE templates, braces doubled, since the const tree is generated and a conversion absent from the template is reverted by the next crawl. * Converted each generator's own %-formatted wrap_comment argument too and dropped their inline disables; those were the last % in either file. * tests/const/test_const_enum_builtin_parity.py: five new tests, and the disable pin flipped -- it asserted the disable was *retained* for this pair. Both templates render their committed const module byte-identically. pylint (Makefile flags plus useless-suppression), mypy and isort report the same findings as 55e1b75. tests/const and tests/vendor: 146 -> 151 tests.
ce992bc to
ed1240d
Compare
|
Rebased onto This is the direct answer to your note here: the six red legs were #819, and your merge of #820 took that defect off
|
|
CI is complete and clean — The six legs that were red here are gone: they were #819, and your merge of #820 took that defect off
One thing to know before merging, since it decides the order: #821 and #826 both touch |
…s in #817 and #821 Two bullets, both non-breaking, appended after the #800 entry in merge order. Bullet count 128 to 130 (`grep -cE '^\* \*\*'`). - #804 (PR #817) -- the three `__repr__` methods #798 left `%`-formatted are f-strings now, dropping `consider-using-f-string` from both const modules and both vendor templates; the other bespoke templates in `{const,vendor}/{ftp,http}/` still carry the disable, so #804's claim holds for this pair only, not for those directories. - #682 (PR #821) -- `TCP.__proto__` no longer binds `httpv1.HTTP` directly for ports 80/8080; both repoint to the generic HTTP proxy `_guess_version` identifies through, which only became reliable once #800/#814 landed. `udp.py` already pointed there, so that side of the PR is prose-only (its port rows and docstring), not a code change, and the entry says so. Protochain over the 23 sample captures is *not* byte-identical: 9 frames in `options-transport.pcap` go `Raw` to `HTTP/2`, all 231 HTTP/1.1 frames are unaffected, and `_guess_version`'s entry count goes 0 to 252. Not marked `**a breaking change to**`: PR #821's own labels are `bug,fix,docs,test`, no `breaking`, unlike #759/#783 and #805/#811 last round, whose crediting PRs did carry it. The entry does say what a `breaking`-blind reader would still want to know -- TCP:80/8080 traffic that is neither valid HTTP/1 nor preface-carrying now reaches `_guess_version`'s fall-through arm instead of the direct `httpv1` bind's unconditional `Raw`, which is where the 12 (of 252) fall-throughs the PR measured come from. `util/changelog_md.py` regenerated `CHANGELOG.md`, first pass, no line-spanning literal this round; `--check` exit 0. `test_changelog_md.py` 47 passed.
…s in #817 and #821 Two bullets, both non-breaking, appended after the #800 entry in merge order. Bullet count 128 to 130 (`grep -cE '^\* \*\*'`). - #804 (PR #817) -- the three `__repr__` methods #798 left `%`-formatted are f-strings now, dropping `consider-using-f-string` from both const modules and both vendor templates; the other bespoke templates in `{const,vendor}/{ftp,http}/` still carry the disable, so #804's claim holds for this pair only, not for those directories. - #682 (PR #821) -- `TCP.__proto__` no longer binds `httpv1.HTTP` directly for ports 80/8080; both repoint to the generic HTTP proxy `_guess_version` identifies through, which only became reliable once #800/#814 landed. `udp.py` already pointed there, so that side of the PR is prose-only (its port rows and docstring), not a code change, and the entry says so. Protochain over the 23 sample captures is *not* byte-identical: 9 frames in `options-transport.pcap` go `Raw` to `HTTP/2`, all 231 HTTP/1.1 frames are unaffected, and `_guess_version`'s entry count goes 0 to 252. Not marked `**a breaking change to**`: PR #821's own labels are `bug,fix,docs,test`, no `breaking`, unlike #759/#783 and #805/#811 last round, whose crediting PRs did carry it. The entry does say what a `breaking`-blind reader would still want to know -- TCP:80/8080 traffic that is neither valid HTTP/1 nor preface-carrying now reaches `_guess_version`'s fall-through arm instead of the direct `httpv1` bind's unconditional `Raw`, which is where the 12 (of 252) fall-throughs the PR measured come from. `util/changelog_md.py` regenerated `CHANGELOG.md`, first pass, no line-spanning literal this round; `--check` exit 0. `test_changelog_md.py` 47 passed.
Please follow the guide below
You will be asked some questions, please read them carefully and answer honestly
Put an
xinto 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 testpasses, and a test case covers the change — tests cover it, butmake testwas not run in full;tests/constandtests/vendoronlyAdded a changelog entry under
docs/source/changelog/and regeneratedCHANGELOG.md, if the change is user-visible — N/A — changelog centralised in docs(changelog): shared 1.5.0 changelog — long-lived, merges last (#610, #616, #617, #618, #620) #657What is the purpose of your pull request?
Tick the commit type your subject line carries.
fix— corrects a defectfeat— adds a featureperf— changes performance, not behaviourrefactor— changes neither behaviour nor performancetest— tests onlydocs— documentation onlyci— workflows or build toolingchore— anything elseDescription of your pull request and other information
Closes #804. The three
__repr__methods #798 left on%—pcapkit/const/ftp/command.py:40,119andpcapkit/const/http/method.py:42, re-derived at55e1b756e— are f-strings now, soconsider-using-f-stringdrops from both files and from bothpcapkit/vendor/templates. Each generator's own%-formattedwrap_commentargument went with them, dropping their two inline disables: nothing in this pair needs it any more. The other bespoke templates in these directories ({const,vendor}/ftp/return_code.py,{const,vendor}/http/status_code.py,vendor/http/frame.py) and the sharedvendor/default.pyone still carry it, so the issue's "nothing inpcapkit/{const,vendor}/{ftp,http}/needs it" is met for this pair only, not for those directories.Generated, so both sides changed. Rendering each
LINEtemplate with the real arguments reproduces its committed const module byte-for-byte; diffing the render against55e1b756egives 6 changed lines forftp/commandand 4 forhttp/method— the intended pairs, nothing else. No crawl: the enumeration block is read back out of the committed module.The conversions are inert, derived rather than assumed — #796's text claimed an equivalence in generated output that
wrap_comment'stextwrap.wraphad masked.repr()is asserted member by member against the old%expression's own output for all ofCommand,FEATCodeandMethod, including adescofNone; both generators'process()output is asserted the same way, on synthetic rows, over both the truthy and falsyrfcsbranch.pylint(Makefile flags plususeless-suppression),mypyandisortreport exactly the same findings as55e1b756e, and nouseless-suppressionfor the dropped disable either side.Tests.
tests/const/test_const_enum_builtin_parity.py22 → 27 tests.test_the_disable_drops_only_where_nothing_else_needs_percent_formattingasserted the opposite for this pair — that the disable was retained, and why — so it is flipped rather than added to. Against stock55e1b756e8 subtests across 3 methods fail; after, 27 tests / 701 subtests pass, agreeing underpython -m unittest(27 OK). The%-format detector is anastwalk overBinOp(Constant(str) % x), self-tested on 3 known-positives and 4 known-negatives first: the issue's own grep'[^']*%[sdr]reads 0 on these files because every surviving line was double-quoted. Note that walk reports 1%site per vendor module where the issue's table said 3 and 2 — inside a template the__repr__lines are string content, not expressions.Coverage over
tests/const+tests/vendor(146 → 151 tests):const/ftp/command.py96.800% → 100.000%,const/http/method.py95.833% → 97.222%,vendor/ftp/command.py26.316% → 78.947%,vendor/http/method.py83.019% → 86.792%. All three converted__repr__lines were previously uncovered.