Repository navigation
chore: remove dead code and outdated guards - #4103
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files
|
henryiii
force-pushed
the
henryiii/python-dead-code
branch
from
June 11, 2026 19:44
82484d1 to
a955ffe
Compare
- regulararray.py, _util.py: drop tostring() fallback (removed from NumPy long ago) - _errors.py: remove numpy 1.13 version guard (requires >=1.21.3) - numpy_like.py, numpytype.py: move float16 into class body; remove always-true hasattr guard (exists since NumPy 1.6); keep float128/complex256 guards (platform-dependent) - _backends/backend.py, forms/form.py: replace typing.Tuple with builtin tuple[...] (Python >=3.10) - _backends/typetracer.py: delete dead _coerce_ufunc_argument (only reference was its own recursion) - _slicing.py: delete unreachable branch where option/indexed node contains option/indexed content (all five constructors forbid this) - contents/indexedarray.py: simplify _unique_index to its effective one-liner - contents/recordarray.py: collapse byte-identical if/else branches in _pad_none - listarray.py, indexedarray.py, indexedoptionarray.py: drop duplicate known_data self-conjunctions; drop duplicate nplike assignment Assisted-by: ClaudeCode:claude-sonnet-4-6
henryiii
force-pushed
the
henryiii/python-dead-code
branch
from
July 7, 2026 17:55
a955ffe to
c00cf2a
Compare
ikrommyd
reviewed
Jul 11, 2026
ikrommyd
approved these changes
Jul 11, 2026
Contributor
|
The documentation preview is ready to be viewed at http://preview.awkward-array.org.s3-website.us-east-1.amazonaws.com/PR4103 |
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.
🤖 AI text below 🤖
Summary
Dead-code removal across 13 files, 155 lines deleted. Each item was verified before deletion.
contents/regulararray.py(lines 1558-1567): Removedtostring()fallback in_to_list;ndarray.tostringwas removed from NumPy years ago and every supported nplike hastobytes._util.py(lines 37-41): Sametostring()fallback in thetobytes()helper; simplified to a one-liner._errors.py(lines 136-137): Removednumpy.__version__.startswith("1.13.")guard; project requires NumPy ≥ 1.21.3 perpyproject.toml._nplikes/numpy_like.pyandtypes/numpytype.py: Removedif hasattr(numpy, "float16")guards (exists since NumPy 1.6); movedfloat16directly intoNumpyMetadataclass body. Thefloat128/complex256guards are retained (genuinely platform-dependent)._backends/backend.pyandforms/form.py: ReplacedTuplefromawkward._typingwith builtintuple[...](project requires Python ≥ 3.10)._backends/typetracer.py(lines 33-42): Deleted deadTypeTracerBackend._coerce_ufunc_argument; grep confirmed its only reference was its own recursion. Cleaned up now-unused imports._slicing.py(lines 368-387): Deleted unreachable branch handling an indexed/option node whose content is also indexed/option (returning the item unchanged, which would infinitely recurse). Verified that all five option/indexed Content constructors (IndexedArray,IndexedOptionArray,ByteMaskedArray,BitMaskedArray,UnmaskedArray) raiseTypeErrorwhen given option/indexed content — making this path structurally impossible.contents/indexedarray.py(lines 746-789): Reduced_unique_indexto its effective behavior:Index64(nplike.unique_values(self._index.data)). The original method ignored itsindexparameter, unconditionally overwrote its initial allocations, and passed theIndexwrapper instead of.datatounique_values. Updated the single caller to drop the now-unused argument.contents/recordarray.py(lines 1126-1141): Collapsed byte-identicalif/elsebranches in_pad_none.contents/listarray.py,contents/indexedarray.py,contents/indexedoptionarray.py: Dropped duplicateself._backend.nplike.known_data and self._backend.nplike.known_dataself-conjunctions. Dropped duplicatenplike = backend.nplikeassignment inindexedoptionarray.py.Test plan
prek -a --quiet— all hooks pass (ruff, mypy, end-of-file fixer auto-corrected, then clean)pytest tests/ -k "unique or pad_none or to_list or slice or typetracer or indexed or record or float16" -q: 873 passed, 58 skipped (skips are missing optional deps: ROOT, numba, JAX, TF, torch)AI assistance: Claude Code (claude-sonnet-4-6), automated multi-agent review
🤖 Generated with Claude Code