[ty] Validate augmented assignment stores - #27545
Open
charliermarsh wants to merge 7 commits into
Open
Conversation
Typing conformance resultsNo changes detected ✅Current numbersThe percentage of diagnostics emitted that were expected errors held steady at 96.96%. The percentage of expected errors that received a diagnostic held steady at 92.96%. The number of fully passing files held steady at 106/133. |
Memory usage reportSummary
Significant changesClick to expand detailed breakdownsphinx
prefect
trio
flake8
|
|
| Lint rule | Added | Removed | Changed |
|---|---|---|---|
unresolved-attribute |
3 | 34 | 3 |
unused-type-ignore-comment |
0 | 11 | 0 |
invalid-assignment |
10 | 0 | 0 |
not-subscriptable |
8 | 0 | 0 |
unsupported-operator |
0 | 0 | 7 |
invalid-argument-type |
1 | 0 | 0 |
| Total | 22 | 45 | 10 |
Flaky changes detected. This PR summary excludes flaky changes; see the HTML report for details.
Raw diff (77 changes)
aiohttp-devtools (https://github.com/aio-libs/aiohttp-devtools)
+ aiohttp_devtools/runserver/serve.py:90:56 error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `bytes | bytearray | Payload | None`
apprise (https://github.com/caronc/apprise)
+ apprise/plugins/telegram.py:1963:13 error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
dd-trace-py (https://github.com/DataDog/dd-trace-py)
- ddtrace/internal/telemetry/writer.py:323:12 error[unsupported-operator] Operator `>` is not supported between objects of type `float` and `EnvVariable[float]`
+ ddtrace/internal/telemetry/writer.py:323:12 error[unsupported-operator] Operator `>` is not supported between objects of type `float | Unknown` and `EnvVariable[float]`
graphql-core (https://github.com/graphql-python/graphql-core)
- tests/pyutils/test_inspect.py:28:46 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- tests/pyutils/test_inspect.py:32:50 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- tests/pyutils/test_inspect.py:37:39 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- tests/pyutils/test_inspect.py:41:44 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- tests/pyutils/test_inspect.py:46:40 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- tests/pyutils/test_inspect.py:50:45 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
manticore (https://github.com/trailofbits/manticore)
- manticore/platforms/evm.py:2982:9 error[unresolved-attribute] Object of type `Self@add_refund` has no attribute `_refund`
- manticore/platforms/evm.py:2985:9 error[unresolved-attribute] Object of type `Self@sub_refund` has no attribute `_refund`
+ scripts/binaryninja/manticore_viz/__init__.py:149:13 error[invalid-assignment] Invalid subscript assignment with key of type `Literal[0]` and value of type `float` on object of type `list[int]`
+ scripts/binaryninja/manticore_viz/__init__.py:151:17 error[invalid-assignment] Invalid subscript assignment with key of type `Literal[0]` and value of type `float` on object of type `list[int]`
mongo-python-driver (https://github.com/mongodb/mongo-python-driver)
+ pymongo/ssl_support.py:120:13 error[invalid-assignment] Object of type `int | Any` is not assignable to attribute `options` on type `pymongo.pyopenssl_context.SSLContext | ssl.SSLContext`
+ pymongo/ssl_support.py:121:13 error[invalid-assignment] Object of type `int | Any` is not assignable to attribute `options` on type `pymongo.pyopenssl_context.SSLContext | ssl.SSLContext`
+ pymongo/ssl_support.py:122:13 error[invalid-assignment] Object of type `int | Any` is not assignable to attribute `options` on type `pymongo.pyopenssl_context.SSLContext | ssl.SSLContext`
+ pymongo/ssl_support.py:123:13 error[invalid-assignment] Object of type `Any | int` is not assignable to attribute `options` on type `pymongo.pyopenssl_context.SSLContext | ssl.SSLContext`
pandas (https://github.com/pandas-dev/pandas)
+ pandas/tests/arithmetic/test_datetime64.py:2187:13 error[invalid-assignment] Cannot assign to read-only property `values` on object of type `TimedeltaIndex`: Attempted assignment to `TimedeltaIndex.values` here
+ pandas/tests/arithmetic/test_datetime64.py:2190:13 error[invalid-assignment] Cannot assign to read-only property `_values` on object of type `TimedeltaIndex`: Attempted assignment to `TimedeltaIndex._values` here
pip (https://github.com/pypa/pip)
- src/pip/_vendor/pygments/filters/__init__.py:833:12 error[unresolved-attribute] Object of type `Self@__init__` has no attribute `tabs`
- src/pip/_vendor/pygments/filters/__init__.py:834:13 error[unresolved-attribute] Object of type `Self@__init__` has no attribute `tabs`
- src/pip/_vendor/pygments/filters/__init__.py:835:12 error[unresolved-attribute] Object of type `Self@__init__` has no attribute `newlines`
- src/pip/_vendor/pygments/filters/__init__.py:836:13 error[unresolved-attribute] Object of type `Self@__init__` has no attribute `newlines`
- src/pip/_vendor/pygments/filters/__init__.py:842:20 error[unresolved-attribute] Object of type `Self@filter` has no attribute `tabs`
- src/pip/_vendor/pygments/filters/__init__.py:843:24 error[unresolved-attribute] Object of type `Self@filter` has no attribute `newlines`
- src/pip/_vendor/pygments/filters/__init__.py:859:51 error[unresolved-attribute] Object of type `Self@filter` has no attribute `tabs`
- src/pip/_vendor/pygments/filters/__init__.py:859:62 error[unresolved-attribute] Object of type `Self@filter` has no attribute `newlines`
pywin32 (https://github.com/mhammond/pywin32)
- pythonwin/pywin/scintilla/formatter.py:670:24 error[unresolved-attribute] Object of type `Self@RegisterStyle` has no attribute `nextstylenum`
- pythonwin/pywin/scintilla/formatter.py:671:13 error[unresolved-attribute] Object of type `Self@RegisterStyle` has no attribute `nextstylenum`
scikit-learn (https://github.com/scikit-learn/scikit-learn)
+ sklearn/decomposition/_lda.py:155:13 error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
+ sklearn/ensemble/_hist_gradient_boosting/gradient_boosting.py:873:25 error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
+ sklearn/preprocessing/_polynomial.py:1079:25 error[invalid-assignment] Invalid subscript assignment with key of type `tuple[slice[None, None, None], slice[None, Unknown | int, None]]` and value of type `lil_array[float64]` on object of type `lil_array[float64]`
scipy (https://github.com/scipy/scipy)
- scipy/optimize/_hessian_update_strategy.py:214:29 error[unresolved-attribute] Attribute `dtype` is not defined on `None`, `int`, `float*` in union `None | ndarray[tuple[int, int], dtype[Any]] | float | ndarray[tuple[Any, ...], dtype[Any]]`
+ scipy/optimize/_hessian_update_strategy.py:214:29 error[unresolved-attribute] Attribute `dtype` is not defined on `None`, `int`, `float*` in union `None | ndarray[tuple[int, int], dtype[Any]] | float | ... omitted 3 union elements`
- scipy/optimize/_hessian_update_strategy.py:217:29 error[unresolved-attribute] Attribute `dtype` is not defined on `None`, `int`, `float*` in union `None | ndarray[tuple[int, int], dtype[Any]] | float | ndarray[tuple[Any, ...], dtype[Any]]`
+ scipy/optimize/_hessian_update_strategy.py:217:29 error[unresolved-attribute] Attribute `dtype` is not defined on `None`, `int`, `float*` in union `None | ndarray[tuple[int, int], dtype[Any]] | float | ... omitted 3 union elements`
- scipy/optimize/_hessian_update_strategy.py:239:21 error[unsupported-operator] Operator `*=` is not supported between objects of type `None` and `float* | ndarray[tuple[Any, ...], dtype[Any]]`
+ scipy/optimize/_hessian_update_strategy.py:239:21 error[unsupported-operator] Operator `*=` is not supported between objects of type `None` and `float* | ndarray[tuple[Any, ...], dtype[Unknown]]`
- scipy/optimize/_hessian_update_strategy.py:244:21 error[unsupported-operator] Operator `*=` is not supported between objects of type `None` and `float* | ndarray[tuple[Any, ...], dtype[Any]]`
+ scipy/optimize/_hessian_update_strategy.py:244:21 error[unsupported-operator] Operator `*=` is not supported between objects of type `None` and `float* | ndarray[tuple[Any, ...], dtype[Unknown]]`
+ scipy/optimize/_nonlin.py:1366:9 error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
+ scipy/optimize/_slsqp_py.py:370:9 error[invalid-assignment] Invalid subscript assignment with key of type `Unknown` and value of type `tuple[dict[str, Unknown], ...]` on object of type `dict[str, tuple[()]]`
+ scipy/signal/_spectral_py.py:1284:9 error[not-subscriptable] Cannot subscript object of type `Literal[0]` with no `__getitem__` method
+ scipy/signal/_spectral_py.py:1412:9 error[not-subscriptable] Cannot subscript object of type `Literal[0]` with no `__getitem__` method
- scipy/special/_orthogonal.py:187:9 error[unresolved-attribute] Object of type `Self@_scale` has no attribute `_coeffs`
spack (https://github.com/spack/spack)
- lib/spack/spack/vendor/macholib/MachO.py:411:13 error[unsupported-operator] Operator `+` is not supported between objects of type `None | Unknown` and `None | int`
+ lib/spack/spack/vendor/macholib/MachO.py:411:13 error[unsupported-operator] Operator `+` is not supported between objects of type `None | Unknown` and `None | int | Unknown`
- lib/spack/spack/vendor/macholib/MachO.py:419:21 error[unsupported-operator] Operator `+` is not supported between objects of type `None | Unknown` and `None | int`
+ lib/spack/spack/vendor/macholib/MachO.py:419:21 error[unsupported-operator] Operator `+` is not supported between objects of type `None | Unknown` and `None | int | Unknown`
- lib/spack/spack/vendor/pyrsistent/_pvector.py:35:9 error[unresolved-attribute] Unresolved attribute `_count` on type `Self@__new__`
- lib/spack/spack/vendor/pyrsistent/_pvector.py:41:29 error[unresolved-attribute] Object of type `Self@__new__` has no attribute `_count`
- lib/spack/spack/vendor/pyrsistent/_pvector.py:45:16 error[unresolved-attribute] Object of type `Self@__len__` has no attribute `_count`
- lib/spack/spack/vendor/pyrsistent/_pvector.py:59:22 error[unresolved-attribute] Object of type `Self@__getitem__` has no attribute `_count`
- lib/spack/spack/vendor/pyrsistent/_pvector.py:81:64 error[unresolved-attribute] Object of type `Self@__eq__` has no attribute `_count`
- lib/spack/spack/vendor/pyrsistent/_pvector.py:274:18 error[unresolved-attribute] Object of type `Self@set` has no attribute `_count`
- lib/spack/spack/vendor/pyrsistent/_pvector.py:276:21 error[unresolved-attribute] Object of type `Self@set` has no attribute `_count`
- lib/spack/spack/vendor/pyrsistent/_pvector.py:280:38 error[unresolved-attribute] Object of type `Self@set` has no attribute `_count`
- lib/spack/spack/vendor/pyrsistent/_pvector.py:282:34 error[unresolved-attribute] Object of type `Self@set` has no attribute `_count`
- lib/spack/spack/vendor/pyrsistent/_pvector.py:284:17 error[unresolved-attribute] Object of type `Self@set` has no attribute `_count`
- lib/spack/spack/vendor/pyrsistent/_pvector.py:317:13 error[unresolved-attribute] Object of type `Self@_create_new_root` has no attribute `_count`
- lib/spack/spack/vendor/pyrsistent/_pvector.py:329:34 error[unresolved-attribute] Object of type `Self@append` has no attribute `_count`
- lib/spack/spack/vendor/pyrsistent/_pvector.py:333:30 error[unresolved-attribute] Object of type `Self@append` has no attribute `_count`
- lib/spack/spack/vendor/pyrsistent/_pvector.py:350:9 error[unresolved-attribute] Object of type `Self@_mutating_fill_tail` has no attribute `_count`
- lib/spack/spack/vendor/pyrsistent/_pvector.py:361:29 error[unresolved-attribute] Object of type `Self@_mutating_extend` has no attribute `_count`
- lib/spack/spack/vendor/pyrsistent/_pvector.py:389:23 error[unresolved-attribute] Object of type `Self@_push_tail` has no attribute `_count`
spark (https://github.com/apache/spark)
+ python/pyspark/pandas/tests/computation/test_describe.py:61:9 error[unresolved-attribute] Unresolved attribute `A` on type `DataFrame`
+ python/pyspark/pandas/tests/computation/test_describe.py:105:9 error[unresolved-attribute] Unresolved attribute `A` on type `DataFrame`
+ python/pyspark/pandas/tests/computation/test_describe.py:131:9 error[unresolved-attribute] Unresolved attribute `A` on type `DataFrame`
+ python/pyspark/pandas/tests/series/test_string_ops_basic.py:59:9 error[not-subscriptable] Cannot subscript object of type `Index` with no `__getitem__` method
static-frame (https://github.com/static-frame/static-frame)
- static_frame/core/type_blocks.py:4165:67 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- static_frame/core/type_blocks.py:4207:67 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- static_frame/core/type_blocks.py:4223:63 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
stone (https://github.com/dropbox/stone)
- stone/frontend/lexer.py:69:34 error[unsupported-operator] Operator `>` is not supported between objects of type `None | int` and `Literal[0]`
+ stone/frontend/lexer.py:69:34 error[unsupported-operator] Operator `>` is not supported between objects of type `None | int | Unknown` and `Literal[0]`
- stone/frontend/lexer.py:78:46 error[unsupported-operator] Operator `*` is not supported between objects of type `list[Unknown]` and `None | int`
+ stone/frontend/lexer.py:78:46 error[unsupported-operator] Operator `*` is not supported between objects of type `list[Unknown]` and `None | int | Unknown`
sympy (https://github.com/sympy/sympy)
- sympy/geometry/polygon.py:1695:16 error[unresolved-attribute] Object of type `Self@rotation` has no attribute `_rot`
- sympy/geometry/polygon.py:1943:9 error[unresolved-attribute] Object of type `Self@spin` has no attribute `_rot`
- sympy/geometry/polygon.py:1965:9 error[unresolved-attribute] Object of type `Self@rotate` has no attribute `_rot`
- sympy/geometry/polygon.py:2048:15 error[unresolved-attribute] Object of type `Self@vertices` has no attribute `_rot`
- sympy/geometry/polygon.py:1533:53 error[unresolved-attribute] Object of type `Self@args` has no attribute `_rot`
+ sympy/logic/boolalg.py:3020:21 error[not-subscriptable] Cannot subscript object of type `int` with no `__getitem__` method
- sympy/matrices/repmatrix.py:743:24 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- sympy/matrices/repmatrix.py:747:24 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- sympy/physics/continuum_mechanics/column.py:565:23 error[unresolved-attribute] Object of type `int` has no attribute `subs`
+ sympy/physics/continuum_mechanics/column.py:565:23 error[unresolved-attribute] Attribute `subs` is not defined on `int` in union `int | Expr | Unknown`
charliermarsh
force-pushed
the
charlie/ty-2175-augmented-assignment-stores
branch
3 times, most recently
from
August 6, 2026 22:23
02a47f6 to
b44e0a4
Compare
Merging this PR will not alter performance
Comparing Footnotes
|
charliermarsh
force-pushed
the
charlie/ty-2175-augmented-assignment-stores
branch
2 times, most recently
from
August 7, 2026 00:22
435bc6d to
14bf332
Compare
charliermarsh
force-pushed
the
charlie/ty-2175-augmented-assignment-stores
branch
from
August 7, 2026 02:15
14bf332 to
bdd36b3
Compare
Member
Author
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.
Summary
Previously, augmented assignments validated the operator but not the assignment of its result back to an attribute or subscript:
We now validate augmented attribute and subscript stores through the same statement-level assignment machinery as ordinary assignments, including property setters, descriptors, read-only targets,
Final,ClassVar,TypedDictentries, and union receivers and keys. Failed operators preserve their recovery types without triggering a write.We also include augmented assignments when inferring public instance-attribute types, which lets inferred attributes evolve without assignment-specific exemptions. Existing receiver-correlation and unannotated-collection inference limitations remain out of scope.
Closes astral-sh/ty#2175.