Skip to content

Conversation

MatthewMckee4
Copy link
Contributor

@MatthewMckee4 MatthewMckee4 commented Jul 30, 2025

Summary

Resolves astral-sh/ty#862 by not emitting a diagnostic.

Test Plan

Add test to show we don't emit the diagnostic

@MatthewMckee4 MatthewMckee4 changed the title Fix set attr diagnostic [ty] Fix incorrect diagnostic when calling __setattr__ Jul 30, 2025
@MatthewMckee4 MatthewMckee4 changed the title [ty] Fix incorrect diagnostic when calling __setattr__ [ty] Fix incorrect diagnostic when calling __setattr__ with no __getattr__ Jul 30, 2025
@MatthewMckee4 MatthewMckee4 changed the title [ty] Fix incorrect diagnostic when calling __setattr__ with no __getattr__ [ty] Fix incorrect diagnostic when calling __setattr__ Jul 30, 2025
Copy link
Contributor

github-actions bot commented Jul 30, 2025

Diagnostic diff on typing conformance tests

No changes detected when running ty on typing conformance tests ✅

@AlexWaygood AlexWaygood added the ty Multi-file analysis & type inference label Jul 30, 2025
@AlexWaygood AlexWaygood changed the title [ty] Fix incorrect diagnostic when calling __setattr__ [ty] Fix incorrect diagnostic when calling __setitem__ Jul 30, 2025
Copy link
Contributor

github-actions bot commented Jul 30, 2025

mypy_primer results

Changes were detected when running on open source projects
pybind11 (https://github.com/pybind/pybind11)
- tests/test_sequences_and_iterators.py:157:5: error[non-subscriptable] Cannot subscript object of type `reversed[Unknown]` with no `__getitem__` method
- Found 210 diagnostics
+ Found 209 diagnostics

pydantic (https://github.com/pydantic/pydantic)
- pydantic/main.py:109:5: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- Found 765 diagnostics
+ Found 764 diagnostics

apprise (https://github.com/caronc/apprise)
- apprise/plugins/dbus.py:431:9: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- apprise/plugins/dbus.py:439:13: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- apprise/plugins/dbus.py:442:13: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- apprise/plugins/dbus.py:446:13: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- apprise/plugins/dbus.py:449:13: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- apprise/plugins/gnome.py:260:9: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- apprise/plugins/gnome.py:268:13: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- apprise/plugins/gnome.py:273:13: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- apprise/plugins/macosx.py:240:9: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- apprise/plugins/macosx.py:246:13: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- apprise/plugins/macosx.py:250:13: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- apprise/plugins/telegram.py:1174:9: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- apprise/plugins/telegram.py:1178:13: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- apprise/plugins/telegram.py:1183:13: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- apprise/plugins/telegram.py:1188:9: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- apprise/plugins/telegram.py:1192:13: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- apprise/plugins/telegram.py:1196:13: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- apprise/plugins/telegram.py:1199:13: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- apprise/plugins/telegram.py:1203:9: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- apprise/plugins/telegram.py:1206:9: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- apprise/plugins/telegram.py:1209:9: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- apprise/plugins/telegram.py:1214:9: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- apprise/plugins/windows.py:275:9: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- apprise/plugins/windows.py:282:13: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- tests/test_apprise_config.py:265:5: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- tests/test_apprise_config.py:576:5: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- Found 1696 diagnostics
+ Found 1670 diagnostics

aiohttp-devtools (https://github.com/aio-libs/aiohttp-devtools)
- aiohttp_devtools/runserver/serve.py:375:17: error[non-subscriptable] Cannot subscript object of type `under_cached_property[Unknown]` with no `__getitem__` method
- aiohttp_devtools/runserver/serve.py:381:25: error[non-subscriptable] Cannot subscript object of type `under_cached_property[Unknown]` with no `__getitem__` method
- Found 58 diagnostics
+ Found 56 diagnostics

werkzeug (https://github.com/pallets/werkzeug)
- src/werkzeug/utils.py:91:13: error[non-subscriptable] Cannot subscript object of type `object` with no `__getitem__` method
- tests/test_routing.py:604:5: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- Found 366 diagnostics
+ Found 364 diagnostics

colour (https://github.com/colour-science/colour)
- colour/recovery/otsu2018.py:1593:21: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- Found 478 diagnostics
+ Found 477 diagnostics

urllib3 (https://github.com/urllib3/urllib3)
- src/urllib3/contrib/emscripten/fetch.py:402:9: error[non-subscriptable] Cannot subscript object of type `Buffer` with no `__getitem__` method
- Found 396 diagnostics
+ Found 395 diagnostics

vision (https://github.com/pytorch/vision)
- references/classification/utils.py:319:5: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- Found 1482 diagnostics
+ Found 1481 diagnostics

pywin32 (https://github.com/mhammond/pywin32)
- win32/test/test_win32file.py:30:9: error[non-subscriptable] Cannot subscript object of type `PyOVERLAPPEDReadBuffer` with no `__getitem__` method
- win32/test/test_win32file.py:36:9: error[non-subscriptable] Cannot subscript object of type `PyOVERLAPPEDReadBuffer` with no `__getitem__` method
- Found 2004 diagnostics
+ Found 2002 diagnostics

static-frame (https://github.com/static-frame/static-frame)
- static_frame/core/bus.py:553:21: error[non-subscriptable] Cannot subscript object of type `Iterable[Unknown | type[FrameDeferred]]` with no `__getitem__` method
- Found 1774 diagnostics
+ Found 1773 diagnostics

prefect (https://github.com/PrefectHQ/prefect)
- src/prefect/deployments/base.py:50:5: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- src/prefect/deployments/base.py:51:5: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- Found 3821 diagnostics
+ Found 3819 diagnostics

dd-trace-py (https://github.com/DataDog/dd-trace-py)
- benchmarks/set_http_meta/scenario.py:74:13: error[non-subscriptable] Cannot subscript object of type `int` with no `__getitem__` method
- benchmarks/set_http_meta/scenario.py:80:13: error[non-subscriptable] Cannot subscript object of type `int` with no `__getitem__` method
- Found 6517 diagnostics
+ Found 6515 diagnostics

scikit-learn (https://github.com/scikit-learn/scikit-learn)
- sklearn/decomposition/_lda.py:155:13: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- sklearn/ensemble/_hist_gradient_boosting/gradient_boosting.py:988:25: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- sklearn/metrics/_base.py:184:13: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- sklearn/preprocessing/tests/test_function_transformer.py:92:5: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- sklearn/utils/_encode.py:77:13: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- sklearn/utils/_encode.py:80:13: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- sklearn/utils/_encode.py:313:21: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- Found 2053 diagnostics
+ Found 2046 diagnostics

sympy (https://github.com/sympy/sympy)
- sympy/parsing/autolev/test-examples/ruletest9.py:45:1: error[non-subscriptable] Cannot subscript object of type `<module 'math'>` with no `__getitem__` method
- sympy/polys/matrices/lll.py:82:17: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- sympy/polys/matrices/lll.py:82:23: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
+ sympy/tensor/array/expressions/from_array_to_matrix.py:997:49: warning[unused-ignore-comment] Unused blanket `type: ignore` directive
- sympy/utilities/lambdify.py:1238:13: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- sympy/utilities/lambdify.py:1241:17: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- Found 12934 diagnostics
+ Found 12930 diagnostics

scipy (https://github.com/scipy/scipy)
- scipy/_lib/_array_api.py:772:9: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- scipy/_lib/pyprima/pyprima/src/pyprima/common/preproc.py:211:13: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- scipy/_lib/pyprima/pyprima/src/pyprima/common/preproc.py:212:13: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- scipy/_lib/pyprima/pyprima/src/pyprima/common/preproc.py:229:13: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- scipy/_lib/pyprima/pyprima/src/pyprima/common/preproc.py:230:13: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- scipy/_lib/pyprima/pyprima/src/pyprima/common/preproc.py:231:13: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- scipy/_lib/pyprima/pyprima/src/pyprima/common/preproc.py:232:13: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- scipy/cluster/hierarchy.py:3769:13: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- scipy/cluster/hierarchy.py:3770:9: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- scipy/cluster/hierarchy.py:3772:9: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- scipy/integrate/_ivp/common.py:241:9: error[non-subscriptable] Cannot subscript object of type `signedinteger[@Todo(Support for `typing.TypeAlias`)]` with no `__getitem__` method
- scipy/integrate/_ivp/common.py:242:9: error[non-subscriptable] Cannot subscript object of type `signedinteger[@Todo(Support for `typing.TypeAlias`)]` with no `__getitem__` method
- scipy/integrate/_quad_vec.py:412:21: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- scipy/ndimage/_measurements.py:674:9: error[non-subscriptable] Cannot subscript object of type `signedinteger[@Todo(Support for `typing.TypeAlias`)]` with no `__getitem__` method
- scipy/ndimage/_measurements.py:977:9: error[non-subscriptable] Cannot subscript object of type `signedinteger[@Todo(Support for `typing.TypeAlias`)]` with no `__getitem__` method
- scipy/ndimage/_measurements.py:984:5: error[non-subscriptable] Cannot subscript object of type `signedinteger[@Todo(Support for `typing.TypeAlias`)]` with no `__getitem__` method
- scipy/ndimage/_morphology.py:2387:9: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- scipy/ndimage/_morphology.py:2418:13: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- scipy/optimize/_shgo.py:511:17: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- scipy/signal/_spectral_py.py:1280:9: error[non-subscriptable] Cannot subscript object of type `int` with no `__getitem__` method
- scipy/signal/_spectral_py.py:1408:9: error[non-subscriptable] Cannot subscript object of type `int` with no `__getitem__` method
- scipy/sparse/linalg/_isolve/iterative.py:543:13: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- scipy/sparse/linalg/_isolve/iterative.py:564:9: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- scipy/sparse/linalg/_isolve/iterative.py:995:13: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- scipy/sparse/linalg/_isolve/iterative.py:997:13: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- scipy/sparse/tests/test_coo.py:129:9: error[non-subscriptable] Cannot subscript object of type `coo_array` with no `__getitem__` method
- scipy/spatial/transform/_rotation_spline.py:442:13: error[non-subscriptable] Cannot subscript object of type `signedinteger[@Todo(Support for `typing.TypeAlias`)]` with no `__getitem__` method
- scipy/spatial/transform/_rotation_spline.py:444:13: error[non-subscriptable] Cannot subscript object of type `signedinteger[@Todo(Support for `typing.TypeAlias`)]` with no `__getitem__` method
- scipy/stats/tests/test_binned_statistic.py:346:9: error[non-subscriptable] Cannot subscript object of type `signedinteger[@Todo(Support for `typing.TypeAlias`)]` with no `__getitem__` method
- scipy/stats/tests/test_binned_statistic.py:347:9: error[non-subscriptable] Cannot subscript object of type `signedinteger[@Todo(Support for `typing.TypeAlias`)]` with no `__getitem__` method
- scipy/stats/tests/test_quantile.py:27:5: error[non-subscriptable] Cannot subscript object of type `floating[Any]` with no `__getitem__` method
- Found 6802 diagnostics
+ Found 6771 diagnostics
No memory usage changes detected ✅

@MatthewMckee4
Copy link
Contributor Author

ah thanks

@MatthewMckee4
Copy link
Contributor Author

I'm not sure how to check the conformance tests

@sharkdp
Copy link
Contributor

sharkdp commented Jul 30, 2025

I'm not sure how to check the conformance tests

You can check out the https://github.com/python/typing repository and see the relevant files in its conformance directory.

@sharkdp
Copy link
Contributor

sharkdp commented Jul 30, 2025

I'm not sure how to check the conformance tests

You can check out the https://github.com/python/typing repository and see the relevant files in its conformance directory.

I don't immediately understand how this diff is related to your PR. This looks strange?

@MatthewMckee4
Copy link
Contributor Author

Yeah looks very strange

@sharkdp
Copy link
Contributor

sharkdp commented Jul 30, 2025

/cc @dhruvmanila Looks like maybe the merge base was computed incorrectly for the typing conformance check here?

Edit: check previous version of the PR comment.

@MatthewMckee4
Copy link
Contributor Author

they've gone away now at least

Copy link
Contributor

@sharkdp sharkdp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much!

@sharkdp sharkdp merged commit 4739bc8 into astral-sh:main Jul 30, 2025
37 checks passed
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.

False positive: type checker thinks __getitem__ is required for foo[2] = 2
3 participants