Skip to content

fix(corekit): give unnamed ListField, PayloadField and SchemaField a default name (#1491) - #1493

Merged
JarryShaw merged 1 commit into
mainfrom
fix/1491-listfield-default-name
Oct 9, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
fix/1491-listfield-default-name

Conversation

@JarryShaw

@JarryShaw JarryShaw commented Oct 9, 2026 •

Copy link
Copy Markdown
Owner

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

Description of your pull request and other information

ListField.__init__, PayloadField.__init__ and SchemaField.__init__ set no _name, so .name on an unnamed instance (and on OptionField/ChunkListField) raised AttributeError. Each now uses the hasattr default from FieldBase.__init__ and Field.__init__ (field.py:348, field.py:614): <list>, <option>, <chunklist>, <payload>, <schema>. A name set by __set_name__ still wins. SwitchField and ForwardMatchField delegate to the wrapped field and are unchanged.

New tests/corekit/test_fields_collections_default_name_1491_unit.py. Fail-before: the ListField cases failed (4 failed / 2 passed) against origin/main's collections.py, and the PayloadField/SchemaField cases failed (2 failed / 4 passed) against origin/main's misc.py. With the fix: 6 passed, 2 subtests passed.

Ran (not make test): that file, tests/corekit (474 passed), tests/project (419 passed, 1 skipped), tests/test_docstring_contract.py (7 passed). Lint not run.

Closes #1491

@JarryShaw JarryShaw added fix Pull requests that fix a defect (fix: subject prefix) review: pending No verdict for the current head - never reviewed, or the head moved since the last one labels Oct 9, 2026
…default name (#1491)

ListField.__init__, PayloadField.__init__ and SchemaField.__init__ set no
_name, so .name on an unnamed instance -- and on OptionField and its
subclasses -- raised AttributeError. Default it with the hasattr idiom
FieldBase and Field already use, giving <list>, <option>, <chunklist>,
<payload>, <schema>, and so on.
@JarryShaw
JarryShaw force-pushed the fix/1491-listfield-default-name branch from 6a7b110 to 7ea03dd Compare October 9, 2026 19:45
@JarryShaw JarryShaw changed the title fix(corekit): give an unnamed ListField a default name (#1491) fix(corekit): give unnamed ListField, PayloadField and SchemaField a default name (#1491) Oct 9, 2026
@JarryShaw JarryShaw added review: running A cross-review is in flight against the current head - no verdict yet and removed review: pending No verdict for the current head - never reviewed, or the head moved since the last one labels Oct 9, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Verdict: GOOD TO GO at 7ea03dde4. Cross-reviewed on Sonnet; the author ran on Opus.

  • The fix works. I measured it myself: on origin/main sources the new tests give 6 failed, 2 passed; at head, 6 passed. Unnamed ListField, PayloadField and SchemaField now get <list>, <payload> and <schema>, the field.py:348-349 idiom.
  • Schema names still win. All 23 ListField/OptionField/PayloadField/SchemaField attributes in the SCTP, IPv4 and TCP schemas keep their attribute names, including on copies, because __set_name__ runs after __init__.
  • Subclasses: OptionField, ChunkListField, OptionAreaField and SchemaField give <option>, <chunklist>, <optionarea> and <schema>. Every subclass name ends in Field, so none is garbled.
  • Regression checks: the per-capture to_dict() hashes are identical across all 23 captures. The round-trip files and tests/corekit, tests/project and the docstring contract pass: 900 passed, 1 skipped.

Non-blocking: the leftover #self._name = '<list>' comment in collections.py matches the one field.py:613 keeps.

@JarryShaw JarryShaw added review: good-to-go Cross-review at the current head says ready; CI state is separate and removed review: running A cross-review is in flight against the current head - no verdict yet labels Oct 9, 2026
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Coverage: 89.65% (unit tier, Python 3.14, 7ea03dde4, Unit Tests run success)

Package Statements Missed Branches Partial Cover
pcapkit (top level) 104 4 20 4 93.55%
pcapkit/const 18795 958 2356 871 90.99%
pcapkit/corekit 2113 66 678 33 96.17%
pcapkit/dumpkit 242 2 88 2 98.79%
pcapkit/foundation 2648 98 930 48 94.80%
pcapkit/interface 112 7 40 5 92.11%
pcapkit/protocols 17086 238 4628 190 97.98%
pcapkit/toolkit 539 74 168 3 84.58%
pcapkit/utilities 431 4 124 4 98.56%
pcapkit/vendor 4409 2342 1006 157 43.25%

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

@JarryShaw
JarryShaw merged commit 394a754 into main Oct 9, 2026
40 checks passed
@JarryShaw
JarryShaw deleted the fix/1491-listfield-default-name branch October 9, 2026 20:05
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Pull requests that fix a defect (fix: subject prefix)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

fix(corekit): ListField, PayloadField and SchemaField have no default name

1 participant