refactor(const,vendor): f-string the three remaining %-formatted __repr__ methods - #830
Conversation
…pr__ methods GitHub issue #818, the remainder #817 deliberately left out of scope: - ftp.ReturnCode, http.StatusCode, pcapng.OptionType each still had a %-formatted __repr__, in both the generated pcapkit/const/*.py module and the pcapkit/vendor/*.py template that emits it. Converted both halves of each pair to an f-string. - Derived the set with an ast.BinOp/ast.Mod walk scoped to __repr__ rather than trusting #818's own headline count of eight: that count folds in pcapkit.const.http.{error_code,frame,setting}, whose % lives in _missing_ (the shared pcapkit.vendor.default template, out of scope here per the issue's own last comment) and pcapkit.const.reg.apptype.apptype, already an f-string since #792 and off-limits while #815 owns that tree. - Regenerated each const module by calling its vendor template's LINE lambda with parameters extracted from the committed file, verifying the old template round-trips byte-for-byte first, rather than hand-editing generated output. - Extended tests/const/test_const_enum_builtin_parity.py with an ISSUE_818_TRIPLE mirroring #804's ISSUE_804_PAIR: an AST check scoped to __repr__ (the module-wide check can't be reused, since __str__ and _missing_ in these three keep their % on purpose), a check on the vendor template text, and a member-by-member repr() parity check against the old %-formatted expression for all 161 members. Verified repr() byte-identical for every member of all three enums before and after, on both the hand-derived and regenerated files. Build: coverage run -m pytest tests/const/ tests/vendor/ (scoped, per this repo's guidance against the full suite); 39263 passed, __repr__ lines newly covered where they were previously missed.
|
Cross-review verdict: GOOD TO GO (opus; author was sonnet). The conclusion holds, and the review refutes the per-file numbers I published — which I have now re-derived myself. My The substantive error: the three So "the disables were correctly left in place on all six" is vacuous on the vendor half. The three Verified independently and not in dispute: all 161 members' Two corrections to the test claims: 2 of the 4 new tests fail on stock, not all four (6 subtest failures across two), and one of the passers is tautological on stock since it compares Four non-blocking findings recorded below. |
|
Four follow-up findings from the cross-review, none blocking this PR. 1. The vendor test does not test the property that can actually break. 2. 3. 4. The AST helper's blind spots, all acceptable but worth knowing. Items 1 and 2 are test-quality improvements in a file this PR already touches; if they are wanted they are cheap to fold in now, otherwise they want their own issue. Item 3 is one sentence of PR prose. Item 4 is informational. |
|
Addendum, corroboration only: the full-flag Under the repo's exact The reviewer flagged its own limitation, which is worth keeping visible: it piped that run through That does not move the conclusion, because the decisive measurement was the other run — pragmas stripped, a single check enabled, full output captured — which gave |
Closes #818
make pylint,make mypy,make isort)make testpasses, and a test case covers the changeWhat is the purpose of your pull request?
fixfeatperfrefactortestdocscichoreDescription
The three
__repr__methods #817 left out of scope:ftp.ReturnCode,http.StatusCode,pcapng.OptionType— const module and vendor template each.Derived via an
astwalk scoped to__repr__, not #818's count of eight(which folds in unrelated
_missing_guards and the already-convertedapptype, split out per the issue's last comment).Const modules regenerated from their vendor
LINEtemplate (round-trippedagainst the old template first) rather than hand-edited.
repr()verifiedbyte-identical for all 161 members, before and after.
Extended
test_const_enum_builtin_parity.pywith anISSUE_818_TRIPLEmirroring
ISSUE_804_PAIR. New tests fail on stockc287152d7.coverage run -m pytest tests/const/ tests/vendor/test_ftp_return_code_unit.py:39263 passed before and after; the three
__repr__lines move to covered.