You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(corekit): before Python 3.10 an Info subclass with no annotations of its own inherits Info's, so its generated __init__ takes the wrong arguments #1692
Describe the bug pcapkit/corekit/infoclass.py:170 reads cls_.__annotations__ for each class in the MRO.
Before Python 3.10 (bpo-43901), a class body with no annotations has no __annotations__ of its own, so the lookup returns the nearest base's. For a direct Info subclass that is Info's own __finalised__, __additional__ and __excluded__.
The generated constructor therefore differs by version:
Building such a subclass from a mapping raises TypeError on 3.6–3.9.
Reproduction
Three tests fail on both legs:
tests/corekit/test_infoclass.py::InfoClassTests::test_auto_finalised_info_mapping_update_and_builtin_key_remapping: __init__() got an unexpected keyword argument 'extra'.
Two in tests/utilities/test_stacklevel.py::StacklevelAttributionTests, through Probe(Info) at :83: __init__() missing 3 required positional arguments: '__finalised__', '__additional__', and '__excluded__'.
Expected behavior
Read only a class's own annotations, cls_.__dict__.get('__annotations__', {}). The same pre-3.10 pitfall may affect four writes to cls.__annotations__[...], which would write into a base's dict: pcapkit/protocols/internet/ipv4.py:74, :150, :345 and pcapkit/protocols/internet/ipv6.py:76. I have not checked those.
Found while triaging main's KTLO legs at f20d0a600: Python 3.8 (KTLO) job 115570853800 (27 failed) and Python 3.9 (KTLO) job 115570853966 (9 failed). Since #1672, KTLO legs exit 0, so this shows only as a ::warning. Reproduced locally on CPython 3.8.20 and 3.9.25.
Activity
fix(corekit): read only a class's own annotations when building an In…