Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[ty] Preserve unpacking diagnostics for nested assignment targets#26121

Merged
charliermarsh merged 3 commits into
mainfrom
cjm/3801-missing-unpacking-assignment-errors
Jun 18, 2026
Merged

[ty] Preserve unpacking diagnostics for nested assignment targets#26121
charliermarsh merged 3 commits into
mainfrom
cjm/3801-missing-unpacking-assignment-errors

Conversation

@carljm

@carljm carljm commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Now that we have a statement-level inference query, we can simplify the handling of assignment unpacking and close some diagnostic gaps. We no longer need an UnpackPosition to avoid duplicate diagnostics, since the statement-level query always owns the assignment unpacking. We do need to track unpacking expressions by assignment target in the semantic index, and reuse that unpacking metadata during type inference so nested targets still emit unpacking diagnostics.

Closes astral-sh/ty#3801

Testing

Added mdtest and updated some expectations.

@astral-sh-bot astral-sh-bot Bot added the ty Multi-file analysis & type inference label Jun 18, 2026
@astral-sh-bot astral-sh-bot Bot changed the title Preserve unpacking diagnostics for nested assignment targets [ty] Preserve unpacking diagnostics for nested assignment targets Jun 18, 2026
@astral-sh-bot

astral-sh-bot Bot commented Jun 18, 2026

Copy link
Copy Markdown

Typing conformance results

No changes detected ✅

Current numbers
The percentage of diagnostics emitted that were expected errors held steady at 94.37%. The percentage of expected errors that received a diagnostic held steady at 89.00%. The number of fully passing files held steady at 94/134.

@astral-sh-bot

astral-sh-bot Bot commented Jun 18, 2026

Copy link
Copy Markdown

Memory usage report

Summary

Project Old New Diff Outcome
prefect 526.43MB 526.51MB +0.01% (78.81kB)
sphinx 198.87MB 198.91MB +0.02% (38.60kB)
trio 81.16MB 81.17MB +0.02% (17.36kB)
flake8 33.02MB 33.03MB +0.02% (5.92kB)

Significant changes

Click to expand detailed breakdown

prefect

Name Old New Diff Outcome
semantic_index 120.43MB 120.48MB +0.05% (58.68kB)
infer_scope_types_impl 38.97MB 38.99MB +0.05% (18.31kB)
Type<'db>::class_member_with_policy_ 10.93MB 10.93MB +0.01% (848.00B)
Type<'db>::class_member_with_policy_::interned_arguments 5.70MB 5.70MB +0.01% (416.00B)
StringLiteralType 5.84MB 5.84MB +0.01% (320.00B)
member_lookup_with_policy_inner::interned_arguments 6.70MB 6.70MB +0.00% (120.00B)
member_lookup_with_policy_inner 14.25MB 14.25MB +0.00% (104.00B)
infer_expression_types_impl 56.76MB 56.76MB +0.00% (36.00B)
infer_definition_types 69.34MB 69.34MB +0.00% (24.00B)

sphinx

Name Old New Diff Outcome
semantic_index 39.51MB 39.53MB +0.06% (25.83kB)
infer_scope_types_impl 10.53MB 10.54MB +0.06% (6.76kB)
infer_unpack_types 501.52kB 505.27kB +0.75% (3.75kB)
Type<'db>::class_member_with_policy_ 5.03MB 5.03MB +0.02% (1.07kB)
Type<'db>::class_member_with_policy_::interned_arguments 2.31MB 2.31MB +0.02% (520.00B)
StaticClassLiteral<'db>::implicit_attribute_inner_ 780.62kB 780.89kB +0.04% (280.00B)
StaticClassLiteral<'db>::implicit_attribute_inner_::interned_arguments 504.94kB 505.12kB +0.04% (192.00B)
member_lookup_with_policy_inner::interned_arguments 2.69MB 2.69MB +0.00% (120.00B)
member_lookup_with_policy_inner 6.00MB 6.00MB +0.00% (104.00B)

trio

Name Old New Diff Outcome
semantic_index 18.97MB 18.97MB +0.04% (8.34kB)
infer_scope_types_impl 3.19MB 3.20MB +0.12% (3.89kB)
Type<'db>::class_member_with_policy_ 1.23MB 1.23MB +0.22% (2.77kB)
Type<'db>::class_member_with_policy_::interned_arguments 613.34kB 614.45kB +0.18% (1.12kB)
member_lookup_with_policy_inner::interned_arguments 763.12kB 763.48kB +0.05% (360.00B)
member_lookup_with_policy_inner 1.50MB 1.50MB +0.02% (312.00B)
infer_expression_types_impl 6.57MB 6.57MB +0.00% (180.00B)
StringLiteralType 531.18kB 531.34kB +0.03% (160.00B)
TypeVarInstance 63.47kB 63.56kB +0.15% (96.00B)
BoundTypeVarInstance 183.67kB 183.75kB +0.04% (80.00B)
infer_definition_types 5.60MB 5.60MB +0.00% (72.00B)
infer_unpack_types 137.66kB 137.67kB +0.01% (12.00B)

flake8

Name Old New Diff Outcome
semantic_index 8.55MB 8.55MB +0.04% (3.40kB)
infer_scope_types_impl 673.37kB 674.86kB +0.22% (1.49kB)
Type<'db>::class_member_with_policy_ 344.70kB 345.09kB +0.11% (400.00B)
member_lookup_with_policy_inner::interned_arguments 204.02kB 204.26kB +0.11% (240.00B)
Type<'db>::class_member_with_policy_::interned_arguments 164.94kB 165.14kB +0.12% (208.00B)
member_lookup_with_policy_inner 430.25kB 430.45kB +0.05% (208.00B)

@astral-sh-bot

astral-sh-bot Bot commented Jun 18, 2026

Copy link
Copy Markdown

ecosystem-analyzer results

Lint rule Added Removed Changed
unresolved-attribute 14 0 0
not-iterable 2 0 0
possibly-unresolved-reference 2 0 0
Total 18 0 0

Flaky changes detected. This PR summary excludes flaky changes; see the HTML report for details.

Raw diff (18 changes)
dd-trace-py (https://github.com/DataDog/dd-trace-py)
+ ddtrace/vendor/ply/lex.py:331:23 error[unresolved-attribute] Unresolved attribute `type` on type `LexToken`

hydpy (https://github.com/hydpy-dev/hydpy)
+ hydpy/core/testtools.py:3131:5 error[unresolved-attribute] Unresolved attribute `model` on type `Device`
+ hydpy/core/testtools.py:3131:16 error[unresolved-attribute] Unresolved attribute `model` on type `Device`
+ hydpy/core/testtools.py:3131:27 error[unresolved-attribute] Unresolved attribute `model` on type `Device`
+ hydpy/core/testtools.py:3131:38 error[unresolved-attribute] Unresolved attribute `model` on type `Device`
+ hydpy/core/testtools.py:3131:49 error[unresolved-attribute] Unresolved attribute `model` on type `Device`
+ hydpy/core/testtools.py:3132:5 error[unresolved-attribute] Unresolved attribute `model` on type `Device`
+ hydpy/core/testtools.py:3132:15 error[unresolved-attribute] Unresolved attribute `model` on type `Device`
+ hydpy/core/testtools.py:3132:25 error[unresolved-attribute] Unresolved attribute `model` on type `Device`
+ hydpy/core/testtools.py:3133:5 error[unresolved-attribute] Unresolved attribute `model` on type `Device`
+ hydpy/core/testtools.py:3133:15 error[unresolved-attribute] Unresolved attribute `model` on type `Device`
+ hydpy/core/testtools.py:3133:25 error[unresolved-attribute] Unresolved attribute `model` on type `Device`

ignite (https://github.com/pytorch/ignite)
+ examples/reinforcement_learning/actor_critic.py:153:9 error[unresolved-attribute] Unresolved attribute `observation` on type `State`
+ examples/reinforcement_learning/reinforce.py:95:9 error[unresolved-attribute] Unresolved attribute `observation` on type `State`

pywin32 (https://github.com/mhammond/pywin32)
+ win32/Lib/sspi.py:173:54 error[not-iterable] Object of type `None` is not iterable

scikit-learn (https://github.com/scikit-learn/scikit-learn)
+ sklearn/linear_model/_least_angle.py:692:17 warning[possibly-unresolved-reference] Name `C_idx` used when possibly not defined
+ sklearn/linear_model/_least_angle.py:742:21 warning[possibly-unresolved-reference] Name `C_idx` used when possibly not defined

yarl (https://github.com/aio-libs/yarl)
+ yarl/_url.py:608:79 error[not-iterable] Object of type `None` is not iterable

Full report with detailed diff (timing results)

@carljm carljm marked this pull request as ready for review June 18, 2026 02:37
@carljm carljm requested review from a team as code owners June 18, 2026 02:37
@astral-sh-bot astral-sh-bot Bot requested a review from charliermarsh June 18, 2026 02:37
@charliermarsh charliermarsh merged commit c0ace18 into main Jun 18, 2026
60 checks passed
@charliermarsh charliermarsh deleted the cjm/3801-missing-unpacking-assignment-errors branch June 18, 2026 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing errors on unpacking subscript assigning

2 participants