refactor(corekit,protocols): normalise the four sentinel objects to SCREAMING_SNAKE (#937) - #939
Conversation
|
NEEDS CHANGES at All five Why it happened. I declared Resolution: this PR takes those three lines. A rename cannot land while leaving an import of the old name behind, and the three references are purely mechanical — Consequence for #940, which also edits this file (+94 lines): the two will conflict on merge. Whichever lands second rebases — normal, and cheaper than splitting the rename. Verified good otherwise, and two findings worth recording:
|
…CREAMING_SNAKE (#937) Rename NoValue -> NO_VALUE and _Absent -> ABSENT (type _AbsentType -> AbsentType), per the owner's ruling on #937: accept the breaking change, no backport. - Update pcapkit/corekit/sentinels.py, its re-export shims (fields/field.py, protocols/protocol.py) and every other call site in pcapkit/ and tests/, including the 3 references in tests/protocols/internet/test_mh_unit.py (:1869, :1875, :1879) -- initially thought off-limits alongside its zero-reference source mh.py (owned by #935), but the test itself was never actually measured. - Keep ABSENT/AbsentType out of every __all__: dropping the underscore removes the mechanical privacy signal, so protocol.py and test_sentinel_exports_unit.py now enforce it by assertion alone. - Document AbsentType/ABSENT on sentinels.rst as explicitly private, since Sphinx no longer hides them automatically; add the object-naming rule to conventions.rst's sentinel-convention section and update its table/prose. - Simplify test_sentinel_exports_unit.py's _expected_type_name to one mechanical rule; add test_every_sentinel_object_is_screaming_snake, confirmed to fail on 3823758 (NoValue, _Absent) and pass here. Build: isort clean (order_by_type sorts NO_VALUE ahead of Field/FieldBase -- a pure casing change reordered 5 files); mypy identical (321/38) and pylint's non-cyclic-import diagnostics identical to origin/main -- cyclic-import counts vary run-to-run even on an unmodified baseline (236 differing lines measured). Targeted suites pass, including the CI-caught mh.py padding test.
8c5feda to
7090f84
Compare
|
GOOD TO GO at The review measured Independently confirmed by the review, each with its own measurement:
It also corrected my brief, and I verified the correction. I told it all four sentinels have re-export shims in UNVERIFIED and worth stating: the coverage delta was not measured (budget), and Unpublished and awaiting you. One coordination note: #940 also edits |
Please follow the guide below
make pylint,make mypy,make isort)make testpasses, and a test case covers the changeWhat is the purpose of your pull request?
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
Implements #937:
NoValue->NO_VALUE,_Absent->ABSENT(type_AbsentType->AbsentType), per the owner's ruling to accept the breaking change with no backport.ABSENT/AbsentTypestay out of every__all__; privacy is now documentation-only (sentinels.rst marks them private explicitly, per the ruling).conventions.rstgains the object-naming rule next to the existing type-naming rule.test_sentinel_exports_unit.py's_expected_type_namecollapses to one mechanical rule, and a new test pins that every object is SCREAMING_SNAKE (confirmed failing on382375811).Also fixes the 3
NoValuereferences intests/protocols/internet/test_mh_unit.py(:1869,:1875,:1879) — nothing else in that file. It was initially treated as off-limits alongside its zero-reference source,mh.py(owned by #935), but the test itself was never actually measured; CI's 5 Python-version legs caught it, failing identically ontest_mh_padding_option_schema_sizes_itself.Two build-tooling notes worth keeping on record:
isortreordered 5 files' imports fromField, NoValuetoNO_VALUE, Field:order_by_typesorts CONSTANT-cased names ahead of Class-cased ones, so a pure casing change alone can reorder imports.pylint'scyclic-import(R0401) output is nondeterministic run-to-run: two runs of the unmodified382375811tree produced 236 differing lines, so R0401 churn can never be pinned on a diff. Every other diagnostic (5,815 lines) was byte-identical against baseline.