pcapkit/protocols/schema/schema.py:77 guards the generated typed __init__
with a test that is always false, because Schema.__init__ is
Schema.__update__:
Schema.__init__ is Schema.__update__: True
So the typed __init__ that schema_final generates is never installed, and in
consequence __post_init__ is never called on any schema.
Why it matters
Two things are quietly not happening:
- Any
__post_init__ a schema defines is inert. Anyone adding one would
reasonably expect it to run, and it will not — silently, with no error.
- The generated signature is what a type checker and an IDE would use to check
Schema(...) construction, so the checking is weaker than it looks.
Whether the fix is to correct the guard or to delete the generation depends on
whether __post_init__ is wanted at all — worth deciding rather than assuming,
since nothing currently relies on it and correcting the guard would start
running hooks that have never run.
Found while profiling for #420 (not a performance issue — noticed in passing).
pcapkit/protocols/schema/schema.py:77guards the generated typed__init__with a test that is always false, because
Schema.__init__isSchema.__update__:So the typed
__init__thatschema_finalgenerates is never installed, and inconsequence
__post_init__is never called on any schema.Why it matters
Two things are quietly not happening:
__post_init__a schema defines is inert. Anyone adding one wouldreasonably expect it to run, and it will not — silently, with no error.
Schema(...)construction, so the checking is weaker than it looks.Whether the fix is to correct the guard or to delete the generation depends on
whether
__post_init__is wanted at all — worth deciding rather than assuming,since nothing currently relies on it and correcting the guard would start
running hooks that have never run.
Found while profiling for #420 (not a performance issue — noticed in passing).