Skip to content

Don't export TypeVars bound by tuple unpacking - #56

Merged
hakancelikdev merged 1 commit into
claude/issuelari-gorme-fpbbfdfrom
fix/tuple-type-vars
Sep 25, 2026
Merged

hakancelikdev merged 1 commit into
claude/issuelari-gorme-fpbbfdfrom
fix/tuple-type-vars

Conversation

@hakancelikdev

Copy link
Copy Markdown
Owner

Review finding on the integration branch (follow-up to #34).

Problem

_rule_name_not_type_var only looked at a Call assigned directly to the name. T, U = TypeVar("T"), TypeVar("U") was therefore exported.

Fix

New _assigned_value follows the target's position through nested tuple/list unpacking to the matching value element. If the shapes don't match (e.g. unpacking a function result), it returns None and the name is treated as before.

Tests

test_type_var_is_not_public now covers A, (B, [C]) = TypeVar(...), (TypeVar(...), [TypeVar(...)]), and a mixed Pair, Name = TypeVar("Pair"), "a string" where Name is still exported. It fails without the fix. 3.10 / 3.12 / 3.14, pre-commit, mypy and the self-check all pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_019P9bvuGwAyVCNUdsAYPB1V


Generated by Claude Code

`T, U = TypeVar("T"), TypeVar("U")` was not recognized because only a
Call assigned directly to the name was checked. The rule now follows the
target's position through nested tuple/list unpacking to its value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019P9bvuGwAyVCNUdsAYPB1V
@hakancelikdev
hakancelikdev merged commit ebab1af into claude/issuelari-gorme-fpbbfd Sep 25, 2026
26 checks passed
hakancelikdev pushed a commit that referenced this pull request Oct 2, 2026
- Bump the version to 0.5.0.
- Date the changelog section and add the entries that were missing for
  #53, #54, #56, #57, #58, #60, #61 and #62.
- Fix license_files: `file: LICENSE` is not a valid glob, so LICENSE was
  left out of the built sdist and wheel.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019P9bvuGwAyVCNUdsAYPB1V
@hakancelikdev
hakancelikdev deleted the fix/tuple-type-vars branch October 2, 2026 22:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants