Repository navigation
refactor(corekit,utilities): detect get_annotations, UnionType and dict reversal by version, not by probe (#1709) - #1730
Merged
Conversation
…ct reversal by version, not by probe (#1709) - compat re-exports get_annotations behind a sys.version_info gate: inspect.get_annotations from 3.10, and below it the reader infoclass had, a class's own __dict__['__annotations__'], uncopied - compat re-exports UnionType: types.UnionType from 3.10, None below it - infoclass and protocol take both from compat in place of their getattr(inspect/types, ...) probes; _own_annotations is gone - MultiInfo and OrderedMultiInfo bind __reversed__ behind sys.version_info >= (3, 8) instead of hasattr(dict, '__reversed__') - _make_index_calls reads an ast call's end_lineno behind sys.version_info >= (3, 8) instead of getattr(node, 'end_lineno', ...) - a project test scans pcapkit/ for getattr/hasattr by literal name of a module or builtin class, or of end_lineno/end_col_offset on any object; on main it reports exactly these six Tests: test_compat, test_infoclass, the probe scan, from_dict, MultiInfo, protocol payload and make() selections pass on 3.8, 3.9, 3.10 and 3.14; 492 Info signatures and nested types byte-identical to main. Closes #1709
Owner
Author
|
Verdict: GOOD TO GO at
|
3 of 13 tasks
Contributor
|
Coverage: 89.35% (unit tier, Python 3.15,
Per-file detail: the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please follow the guide below
You will be asked some questions, please read them carefully and answer honestly
Put an
xinto all the boxes [ ] relevant to your pull request (like that [x])Use Preview tab to see how your pull request will actually look like
Searched for similar pull requests
Followed the coding style (
make pylint,make mypy,make isort)make testpasses, and a test case covers the change. Narrow runs only, listed below.Added a changelog entry under
docs/source/changelog/and regeneratedCHANGELOG.md, if the change is user-visible: N/A — centralised in docs(changelog): shared 1.5.0 changelog — long-lived, merges last (#610, #616, #617, #618, #620) #657What is the purpose of your pull request?
Tick the commit type your subject line carries.
fix— corrects a defectfeat— adds a featureperf— changes performance, not behaviourrefactor— changes neither behaviour nor performancetest— tests onlydocs— documentation onlyci— workflows or build toolingrelease— bumps the version or rolls up a distributionchore— anything elseDescription of your pull request and other information
Closes #1709. This applies the owner's rulings on #1701 and #1703 to the six stdlib feature probes left in
pcapkit/.compatre-exports:get_annotations(3.10+, otherwise a class's own__dict__['__annotations__']) andUnionType(3.10+, otherwiseNone), both behindsys.version_info.infoclassandprotocolimport both from there, and_own_annotationsis gone.MultiInfo/OrderedMultiInfo: they bind__reversed__behindsys.version_info >= (3, 8)instead ofhasattr(dict, '__reversed__')._make_index_calls: it reads an ast call'send_linenobehindsys.version_info >= (3, 8)instead of throughgetattr.tests/project/test_stdlib_feature_probes_1709_unit.pyscanspcapkit/for literal-namegetattr/hasattrcalls on a module or builtin class, or forend_lineno/end_col_offseton any object. It fails onmainand on round 1 of this PR.protocol.py's import lines. Whichever merges second gets rebased.Tests: the compat, infoclass, probe-scan, round-trip and protocol-make selections pass on 3.8, 3.9, 3.10 and 3.14.