fix: resolve IterableList names independently of list attributes by FanWu-ai · Pull Request #2283 · gitpython-developers/GitPython
Repository navigation
fix: resolve IterableList names independently of list attributes - #2283
Merged
Byron merged 1 commit into gitpython-developers:main from FanWu-ai:fix-iterable-list-name-collisions-20261011 Oct 14, 2026
Merged
fix: resolve IterableList names independently of list attributes #2283 Byron merged 1 commit into gitpython-developers:main from FanWu-ai:fix-iterable-list-name-collisions-20261011
Conversation
FanWu-ai commented Oct 11, 2026
Copy link Copy Markdown
Contributor
This PR was prepared by an OpenAI Codex agent.
IterableList string indexing currently uses normal attribute lookup. Consequently, names such as count, sort, or append return list methods rather than matching items, and an absent append is reported as present. This also affects named references and submodules, as described in #1091 (currently closed as not planned).
Route string indexing and identifier membership through the existing identifier lookup, and raise AttributeError when no matching item exists instead of falling back to list attributes. Ordinary attribute access to list methods remains available.
Twelve regression cases cover list-method names, internal/dunder names, ordinary names, and prefixed identifiers, including absence after deletion. Ten fail against pristine source; the two ordinary-name controls pass.
Validation on CPython 3.12.14 / Linux / Git 2.52.0:
- Full pristine suite: 1,689 passed, 89 conditional skips, one existing xfail, 64 subtests.
- Full final suite: 1,701 passed, the same 89 skips and one xfail, 64 subtests (428.45 seconds).
- All nine pinned pre-commit hooks, mypy (46 files), basedpyright (zero errors/warnings), clean Sphinx docs, wheel/sdist build and strict Twine validation passed.
- Wheel and sdist source bytes match the tested checkout;
git diff --checkpassed. - 114 additional name/prefix checks and subclass-override compatibility checks passed.
The unchanged skips are platform/filesystem-specific, and the existing xfail concerns shallow submodules. One unchanged path-environment deprecation warning remains. Other operating systems and Python versions were not run locally; hosted results are reported separately.
fix: resolve IterableList names independently of list attributes
fa45526
Normal attribute lookup makes string indexing return list methods for item names such as `count`, and reports absent `append` identifiers as present. Use `__getattr__` explicitly for identifier lookup and remove its fallback to list attributes. Ordinary attribute access still exposes list methods. Add twelve present/absent collision cases with and without prefixes. The full suite passes 1701 tests, 89 conditional skips, one existing xfail, and 64 subtests; pinned hooks, type checks, docs and packaging also pass.FanWu-ai marked this pull request as ready for review October 11, 2026 18:19 Byron requested a balanced review from Copilot October 12, 2026 05:48 Copilot PR reviewer Copilot
AI
reviewed Oct 12, 2026
View reviewed changes
Copilot
AI
left a comment
Copy link Copy Markdown
Contributor
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more .
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
2 open findings-
__getitem__duplicates the 'No item found...' message formatting that__getattr__already owns,... · New - The new
AttributeErrormessage interpolates the identifier without quoting ({attr}), which can... · New
Updates IterableList name-based lookup so string indexing and membership checks resolve items by identifier rather than colliding with built-in list attributes/methods (e.g., append, sort), and adds regression tests for these edge cases.
Changes:
- Route
__contains__and string__getitem__throughIterableList.__getattr__instead of Python attribute lookup. - Change
__getattr__fallback from list attribute access to raisingAttributeErrorwhen no matching item exists. - Add parametrized regression tests covering list-method names, dunder/internal names, prefixes, and deletion.
| File | Description |
|---|---|
git/util.py |
Adjusts IterableList lookup semantics to avoid list attribute collisions and to raise on missing identifiers. |
test/test_util.py |
Adds regression tests ensuring identifier lookup works even for names that match list methods/dunders and after deletion. |
🧠 Review effort: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
d940ee7
into
gitpython-developers : main
Oct 14, 2026
47 checks passed
FanWu-ai
deleted the
fix-iterable-list-name-collisions-20261011
branch
October 15, 2026 04:00
Sign up for free
to join this conversation on GitHub .
Already have an account?
Sign in to comment