Skip to content

Bind the functools wrapper mutation literal with an empty range (Issue #5670) - #5687

Open
KalininDL wants to merge 1 commit into
pyrefly-org:mainfrom
KalininDL:fix-functools-wrapper-mutation-range
Open

KalininDL wants to merge 1 commit into
pyrefly-org:mainfrom
KalininDL:fix-functools-wrapper-mutation-range

Conversation

@KalininDL

Copy link
Copy Markdown
Contributor

Summary

The synthetic functools wrapper mutation literal was bound with the whole module's range, so its type trace shadowed an expression spanning the whole module (a single expression without a trailing newline). For example, typeServer/getComputedType on [1, 2, 3] returned Literal[False] instead of list[int]. This binds the literal with an empty range, as the empty-bindings constructor already does. Reported errors are unchanged.

Fixes #5670

  • I am a human, and I fully understand the code I am submitting.

Test Plan

  • Added test_get_computed_type_expression_spanning_whole_module to get_type_queries.rs
    It fails before the fix and passes after
  • cargo test --release -p pyrefly --lib (10960 passed, 0 failed) and lint pass.

@meta-codesync

meta-codesync Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

This pull request has been imported. If you are a Meta employee, you can view this in D132914900. (Because this pull request was imported automatically, there will not be any future comments.)

@github-actions

This comment has been minimized.

The synthetic literal used the whole module's range, so its type trace
shadowed an expression spanning the whole module (a single expression
without a trailing newline): range-based type queries returned
`Literal[False]` for it. An empty range, as the empty-bindings
constructor already uses, cannot collide with a real expression.

Fixes pyrefly-org#5670

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@KalininDL
KalininDL force-pushed the fix-functools-wrapper-mutation-range branch from 218475f to d7dd2a0 Compare November 19, 2026 07:33
@github-actions github-actions Bot added size/xs and removed size/xs labels Nov 19, 2026
@github-actions

Copy link
Copy Markdown

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

typeServer/getComputedType returns Literal[False] for an expression whose range equals the whole module

2 participants