Uh oh!
There was an error while loading. Please reload this page.
Sync typeshed - #20729
Conversation
This comment has been minimized.
This comment has been minimized.
Source commit: python/typeshed@11ff7e1
This is allegedly causing large performance problems, see 13821 typeshed/8231 had zero hits on mypy_primer, so it's not the worst thing to undo. Patching this in typeshed also feels weird, since there's a more general soundness issue. If a typevar has a bound or constraint, we might not want to solve it to a Literal. If we can confirm the performance regression or fix the unsoundness within mypy, I might pursue upstreaming this in typeshed. (Reminder: add this to the sync_typeshed script once merged)
The plugin provides superior type checking: python#13987 (comment) A manual cherry-pick of e437cdf.
This comment has been minimized.
This comment has been minimized.
cdce8p
commented
Feb 3, 2026
Mypy primer hits
|
Do you think python/typeshed#12087 is worth it, especially without any linter autofix support in the ecosystem? Want to leave this open for a bit to see if any other maintainers have opinions on it |
cdce8p
commented
Feb 8, 2026
Yes, I think so. The return type for context managers is actually something I struggled with myself for quite some time. I couldn't really find any information only if it should be In the end it's also a fairly simple and strait forward thing to fix. E.g. this was my PR for Home Assistant: home-assistant/core#162144 If |
This comment has been minimized.
This comment has been minimized.
Source commit: python/typeshed@637ece0
This is allegedly causing large performance problems, see 13821 typeshed/8231 had zero hits on mypy_primer, so it's not the worst thing to undo. Patching this in typeshed also feels weird, since there's a more general soundness issue. If a typevar has a bound or constraint, we might not want to solve it to a Literal. If we can confirm the performance regression or fix the unsoundness within mypy, I might pursue upstreaming this in typeshed. (Reminder: add this to the sync_typeshed script once merged)
The plugin provides superior type checking: python#13987 (comment) A manual cherry-pick of e437cdf.
This comment has been minimized.
This comment has been minimized.
cdce8p
commented
Feb 22, 2026
@hauntsaninja I'd like to get this one done. Are you comfortable with the changes here or should I add a patch to revert python/typeshed#12087? Though as mentioned earlier, I think it's fine and there haven't been any other comments. We could also add a patch later if necessary. |
hauntsaninja
commented
Feb 23, 2026
I just checked and I have several thousand spots that would need to be updated in my work codebase. This is a chore and it looks like there's still no linter autofix for it. So I've reverted it in this one. We can take it in the mypy 2.0 typeshed sync and provide guidance in the changelog then. Maybe someone (possibly myself) will get around to a ruff autofix for it too. |
This comment has been minimized.
This comment has been minimized.
Hmm, it looks like this typeshed sync breaks mypy's container overlap check. Previously you got |
| if sys.version_info >= (3, 15): | ||
| # anticipate on https://github.com/python/cpython/pull/139224 | ||
| - _SupportsFloatOrIndex: TypeAlias = SupportsFloat | SupportsIndex |
There was a problem hiding this comment.
what is the lookup error you're seeing? i wasn't able to repro an issue...
There was a problem hiding this comment.
I merged master again. You should be able to see it now.
# pytest -n0 mypyc/test/test_run.py::TestRun::run-librt-time.test::testTimeBasic_librt_experimentalTraceback (mostrecentcalllast):
...
File"/.../mypy/nodes.py", line3239, inacceptreturnvisitor.visit_type_alias_expr(self)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^File"/.../mypy/checkexpr.py", line4868, invisit_type_alias_exprreturnself.alias_type_in_runtime_context(alias.node, ctx=alias, alias_definition=True)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File"/.../mypy/checkexpr.py", line4929, inalias_type_in_runtime_contextreturnself.chk.named_generic_type("types.UnionType", item.items)
~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File"/.../mypy/checker.py", line7494, innamed_generic_typeinfo=self.lookup_typeinfo(name)
File"/.../mypy/checker.py", line7501, inlookup_typeinfosym=self.lookup_qualified(fullname)
File"/.../mypy/checker.py", line7567, inlookup_qualifiedn=self.modules[parts[0]]
~~~~~~~~~~~~^^^^^^^^^^KeyError: 'types'This reverts commit f66e55b.
cdce8p
commented
Feb 23, 2026
Bisected it to python/typeshed#15320. Added a patch to revert it in b379c09 and a regression test 11737d1. |
Diff from mypy_primer, showing the effect of this PR on open source code: prefect (https://github.com/PrefectHQ/prefect)
- src/prefect/deployments/flow_runs.py:441: error: Argument 1 to "sleep" has incompatible type "float | None"; expected "float" [arg-type]+ src/prefect/deployments/flow_runs.py:441: error: Argument 1 to "sleep" has incompatible type "float | None"; expected "float | SupportsIndex" [arg-type]- src/prefect/infrastructure/provisioners/container_instance.py:274: error: Invalid index type "str" for "str"; expected type "SupportsIndex | slice[Any, Any, Any]" [index]+ src/prefect/infrastructure/provisioners/container_instance.py:274: error: Invalid index type "str" for "str"; expected type "SupportsIndex | slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None]" [index]- src/prefect/infrastructure/provisioners/container_instance.py:275: error: Invalid index type "str" for "str"; expected type "SupportsIndex | slice[Any, Any, Any]" [index]+ src/prefect/infrastructure/provisioners/container_instance.py:275: error: Invalid index type "str" for "str"; expected type "SupportsIndex | slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None]" [index]- src/prefect/infrastructure/provisioners/container_instance.py:347: error: Invalid index type "str" for "str"; expected type "SupportsIndex | slice[Any, Any, Any]" [index]+ src/prefect/infrastructure/provisioners/container_instance.py:347: error: Invalid index type "str" for "str"; expected type "SupportsIndex | slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None]" [index]- src/prefect/infrastructure/provisioners/container_instance.py:356: error: Invalid index type "str" for "str"; expected type "SupportsIndex | slice[Any, Any, Any]" [index]+ src/prefect/infrastructure/provisioners/container_instance.py:356: error: Invalid index type "str" for "str"; expected type "SupportsIndex | slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None]" [index]- src/prefect/infrastructure/provisioners/container_instance.py:413: error: Invalid index type "str" for "str"; expected type "SupportsIndex | slice[Any, Any, Any]" [index]+ src/prefect/infrastructure/provisioners/container_instance.py:413: error: Invalid index type "str" for "str"; expected type "SupportsIndex | slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None]" [index]- src/prefect/infrastructure/provisioners/container_instance.py:638: error: Invalid index type "str" for "str"; expected type "SupportsIndex | slice[Any, Any, Any]" [index]+ src/prefect/infrastructure/provisioners/container_instance.py:638: error: Invalid index type "str" for "str"; expected type "SupportsIndex | slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None]" [index]- src/prefect/cli/deploy/_actions.py:164: note: def __setitem__(self, slice[Any, Any, Any], Iterable[dict[str, Any]], /) -> None+ src/prefect/cli/deploy/_actions.py:164: note: def __setitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], Iterable[dict[str, Any]], /) -> None- src/prefect/cli/deploy/_actions.py:192: note: def __setitem__(self, slice[Any, Any, Any], Iterable[dict[str, Any]], /) -> None+ src/prefect/cli/deploy/_actions.py:192: note: def __setitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], Iterable[dict[str, Any]], /) -> None- src/prefect/cli/deploy/_actions.py:200: note: def __setitem__(self, slice[Any, Any, Any], Iterable[dict[str, Any]], /) -> None+ src/prefect/cli/deploy/_actions.py:200: note: def __setitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], Iterable[dict[str, Any]], /) -> None- src/prefect/cli/deploy/_actions.py:221: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[dict[str, Any]]+ src/prefect/cli/deploy/_actions.py:221: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[dict[str, Any]]
aiohttp (https://github.com/aio-libs/aiohttp)
+ aiohttp/web_routedef.py:151:6: error: Signature of "__getitem__" incompatible with supertype "typing.Sequence" [override]+ aiohttp/web_routedef.py:151:6: note: Superclass:+ aiohttp/web_routedef.py:151:6: note: @overload+ aiohttp/web_routedef.py:151:6: note: def __getitem__(self, int, /) -> AbstractRouteDef+ aiohttp/web_routedef.py:151:6: note: @overload+ aiohttp/web_routedef.py:151:6: note: def __getitem__(self, slice[int | None, int | None, int | None], /) -> Sequence[AbstractRouteDef]+ aiohttp/web_routedef.py:151:6: note: Subclass:+ aiohttp/web_routedef.py:151:6: note: @overload+ aiohttp/web_routedef.py:151:6: note: def __getitem__(self, int, /) -> AbstractRouteDef+ aiohttp/web_routedef.py:151:6: note: @overload+ aiohttp/web_routedef.py:151:6: note: def __getitem__(self, slice[int, int, int], /) -> list[AbstractRouteDef]
colour (https://github.com/colour-science/colour)
- colour/models/tests/test_hunter_rdab.py:159: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/models/tests/test_hunter_rdab.py:159: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/models/tests/test_hunter_rdab.py:294: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/models/tests/test_hunter_rdab.py:294: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/models/tests/test_hunter_lab.py:233: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/models/tests/test_hunter_lab.py:233: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/models/tests/test_hunter_lab.py:368: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/models/tests/test_hunter_lab.py:368: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/models/tests/test_hdr_ipt.py:230: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/models/tests/test_hdr_ipt.py:230: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/models/tests/test_hdr_ipt.py:337: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/models/tests/test_hdr_ipt.py:337: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/models/tests/test_hdr_cie_lab.py:251: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/models/tests/test_hdr_cie_lab.py:251: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/models/tests/test_hdr_cie_lab.py:376: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/models/tests/test_hdr_cie_lab.py:376: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/models/tests/test_cie_uvw.py:133: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/models/tests/test_cie_uvw.py:133: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/models/tests/test_cie_uvw.py:243: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/models/tests/test_cie_uvw.py:243: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/models/tests/test_cie_luv.py:148: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/models/tests/test_cie_luv.py:148: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/models/tests/test_cie_luv.py:258: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/models/tests/test_cie_luv.py:258: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/models/tests/test_cie_luv.py:368: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/models/tests/test_cie_luv.py:368: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/models/tests/test_cie_luv.py:485: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/models/tests/test_cie_luv.py:485: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/models/tests/test_cie_luv.py:710: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/models/tests/test_cie_luv.py:710: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/models/tests/test_cie_luv.py:823: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/models/tests/test_cie_luv.py:823: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/models/tests/test_cie_lab.py:133: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/models/tests/test_cie_lab.py:133: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/models/tests/test_cie_lab.py:243: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/models/tests/test_cie_lab.py:243: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/models/rgb/tests/test_rgb_colourspace.py:477: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/models/rgb/tests/test_rgb_colourspace.py:477: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/models/rgb/tests/test_rgb_colourspace.py:677: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/models/rgb/tests/test_rgb_colourspace.py:677: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/colorimetry/tests/test_whiteness.py:475: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/colorimetry/tests/test_whiteness.py:475: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/colorimetry/tests/test_whiteness.py:574: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/colorimetry/tests/test_whiteness.py:574: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/appearance/tests/test_scam.py:215: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/appearance/tests/test_scam.py:215: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/appearance/tests/test_scam.py:404: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/appearance/tests/test_scam.py:404: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/appearance/tests/test_scam.py:406: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/appearance/tests/test_scam.py:406: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/appearance/tests/test_scam.py:407: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/appearance/tests/test_scam.py:407: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/appearance/tests/test_rlab.py:155: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/appearance/tests/test_rlab.py:155: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/appearance/tests/test_nayatani95.py:155: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/appearance/tests/test_nayatani95.py:155: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/appearance/tests/test_llab.py:223: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/appearance/tests/test_llab.py:223: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/appearance/tests/test_llab.py:224: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/appearance/tests/test_llab.py:224: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/appearance/tests/test_llab.py:225: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/appearance/tests/test_llab.py:225: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/appearance/tests/test_llab.py:434: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/appearance/tests/test_llab.py:434: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/appearance/tests/test_llab.py:435: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/appearance/tests/test_llab.py:435: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/appearance/tests/test_llab.py:438: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/appearance/tests/test_llab.py:438: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/appearance/tests/test_llab.py:441: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/appearance/tests/test_llab.py:441: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/appearance/tests/test_kim2009.py:223: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/appearance/tests/test_kim2009.py:223: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/appearance/tests/test_kim2009.py:224: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/appearance/tests/test_kim2009.py:224: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/appearance/tests/test_kim2009.py:225: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/appearance/tests/test_kim2009.py:225: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/appearance/tests/test_kim2009.py:434: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/appearance/tests/test_kim2009.py:434: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/appearance/tests/test_kim2009.py:435: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/appearance/tests/test_kim2009.py:435: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/appearance/tests/test_kim2009.py:438: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/appearance/tests/test_kim2009.py:438: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/appearance/tests/test_kim2009.py:441: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/appearance/tests/test_kim2009.py:441: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/appearance/tests/test_hunt.py:231: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/appearance/tests/test_hunt.py:231: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/appearance/tests/test_hunt.py:236: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/appearance/tests/test_hunt.py:236: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/appearance/tests/test_hunt.py:238: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/appearance/tests/test_hunt.py:238: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/appearance/tests/test_hellwig2022.py:242: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/appearance/tests/test_hellwig2022.py:242: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/appearance/tests/test_hellwig2022.py:243: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/appearance/tests/test_hellwig2022.py:243: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/appearance/tests/test_hellwig2022.py:449: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/appearance/tests/test_hellwig2022.py:449: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/appearance/tests/test_hellwig2022.py:452: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/appearance/tests/test_hellwig2022.py:452: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/appearance/tests/test_hellwig2022.py:455: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/appearance/tests/test_hellwig2022.py:455: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/appearance/tests/test_hellwig2022.py:456: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/appearance/tests/test_hellwig2022.py:456: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/appearance/tests/test_ciecam16.py:264: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/appearance/tests/test_ciecam16.py:264: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/appearance/tests/test_ciecam16.py:265: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/appearance/tests/test_ciecam16.py:265: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/appearance/tests/test_ciecam16.py:465: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/appearance/tests/test_ciecam16.py:465: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/appearance/tests/test_ciecam16.py:468: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/appearance/tests/test_ciecam16.py:468: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/appearance/tests/test_ciecam16.py:471: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/appearance/tests/test_ciecam16.py:471: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/appearance/tests/test_ciecam16.py:472: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]+ colour/appearance/tests/test_ciecam16.py:472: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[float]- colour/appearance/tests/test_ciecam02.py:205: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[float]
... (truncated 43 lines) ...
operator (https://github.com/canonical/operator)
- ops/framework.py:1385: note: def __getitem__(self, slice[Any, Any, Any], /) -> MutableSequence[Any]+ ops/framework.py:1385: note: def __getitem__(self, slice[int | None, int | None, int | None], /) -> MutableSequence[Any]- ops/framework.py:1385: note: def __getitem__(self, slice[Any, Any, Any], /) -> Sequence[Any]+ ops/framework.py:1385: note: def __getitem__(self, slice[int | None, int | None, int | None], /) -> Sequence[Any]- ops/framework.py:1388: note: def __setitem__(self, slice[Any, Any, Any], Iterable[Any], /) -> None+ ops/framework.py:1388: note: def __setitem__(self, slice[int | None, int | None, int | None], Iterable[Any], /) -> None- ops/framework.py:1392: note: def __delitem__(self, slice[Any, Any, Any], /) -> None+ ops/framework.py:1392: note: def __delitem__(self, slice[int | None, int | None, int | None], /) -> None
discord.py (https://github.com/Rapptz/discord.py)
- discord/http.py:242: note: def __setitem__(self, slice[Any, Any, Any], Iterable[Embed], /) -> None+ discord/http.py:242: note: def __setitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], Iterable[Embed], /) -> None
ibis (https://github.com/ibis-project/ibis)
- ibis/legacy/udf/vectorized.py:188: error: Incompatible types in assignment (expression has type "Attribute", variable has type "ExtensionArray | ndarray[tuple[Any, ...], dtype[Any]] | Index[Any] | Series[Any] | SequenceNotStr[Hashable]") [assignment]+ ibis/legacy/udf/vectorized.py:188: error: Incompatible types in assignment (expression has type "Attribute", variable has type "ExtensionArray | ndarray[tuple[Any, ...], dtype[Any]] | Index[Any] | Series[Any] | SequenceNotStr[Hashable] | tuple[Hashable, ...]") [assignment]
scipy (https://github.com/scipy/scipy)
- scipy/spatial/transform/_rotation_xp.py:539: error: Invalid index type "tuple[EllipsisType, None, None]" for "str"; expected type "SupportsIndex | slice[Any, Any, Any]" [index]+ scipy/spatial/transform/_rotation_xp.py:539: error: Invalid index type "tuple[EllipsisType, None, None]" for "str"; expected type "SupportsIndex | slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None]" [index]- scipy/spatial/transform/_rigid_transform_xp.py:300: error: Invalid index type "tuple[EllipsisType, None]" for "str"; expected type "SupportsIndex | slice[Any, Any, Any]" [index]+ scipy/spatial/transform/_rigid_transform_xp.py:300: error: Invalid index type "tuple[EllipsisType, None]" for "str"; expected type "SupportsIndex | slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None]" [index]- scipy/spatial/transform/_rigid_transform_xp.py:301: error: Invalid index type "tuple[EllipsisType, None]" for "str"; expected type "SupportsIndex | slice[Any, Any, Any]" [index]+ scipy/spatial/transform/_rigid_transform_xp.py:301: error: Invalid index type "tuple[EllipsisType, None]" for "str"; expected type "SupportsIndex | slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None]" [index]
manticore (https://github.com/trailofbits/manticore)
- tests/wasm/json2mc.py:103: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[Any]+ tests/wasm/json2mc.py:103: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[Any]
apprise (https://github.com/caronc/apprise)
- apprise/config/base.py:795: error: Invalid index type "str" for "str"; expected type "SupportsIndex | slice[Any, Any, Any]" [index]+ apprise/config/base.py:795: error: Invalid index type "str" for "str"; expected type "SupportsIndex | slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None]" [index]- apprise/config/base.py:804: error: Invalid index type "str" for "str"; expected type "SupportsIndex | slice[Any, Any, Any]" [index]+ apprise/config/base.py:804: error: Invalid index type "str" for "str"; expected type "SupportsIndex | slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None]" [index]- apprise/config/base.py:806: error: Invalid index type "str" for "str"; expected type "SupportsIndex | slice[Any, Any, Any]" [index]+ apprise/config/base.py:806: error: Invalid index type "str" for "str"; expected type "SupportsIndex | slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None]" [index]- apprise/config/base.py:811: error: Invalid index type "str" for "str"; expected type "SupportsIndex | slice[Any, Any, Any]" [index]+ apprise/config/base.py:811: error: Invalid index type "str" for "str"; expected type "SupportsIndex | slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None]" [index]- apprise/config/base.py:816: error: Invalid index type "str" for "str"; expected type "SupportsIndex | slice[Any, Any, Any]" [index]+ apprise/config/base.py:816: error: Invalid index type "str" for "str"; expected type "SupportsIndex | slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None]" [index]- apprise/config/base.py:823: error: Invalid index type "str" for "str"; expected type "SupportsIndex | slice[Any, Any, Any]" [index]+ apprise/config/base.py:823: error: Invalid index type "str" for "str"; expected type "SupportsIndex | slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None]" [index]
freqtrade (https://github.com/freqtrade/freqtrade)
- freqtrade/rpc/telegram.py:408: note: def __getitem__(self, slice[Any, Any, Any], /) -> bytes+ freqtrade/rpc/telegram.py:408: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> bytes- freqtrade/rpc/telegram.py:408: error: Invalid index type "str" for "str"; expected type "SupportsIndex | slice[Any, Any, Any]" [index]+ freqtrade/rpc/telegram.py:408: error: Invalid index type "str" for "str"; expected type "SupportsIndex | slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None]" [index]- freqtrade/rpc/telegram.py:409: note: def __getitem__(self, slice[Any, Any, Any], /) -> bytes+ freqtrade/rpc/telegram.py:409: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> bytes- freqtrade/rpc/telegram.py:409: error: Invalid index type "str" for "str"; expected type "SupportsIndex | slice[Any, Any, Any]" [index]+ freqtrade/rpc/telegram.py:409: error: Invalid index type "str" for "str"; expected type "SupportsIndex | slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None]" [index]- freqtrade/templates/FreqaiExampleStrategy.py:287: note: def __getitem__(self, slice[Any, Any, Any], /) -> bytes+ freqtrade/templates/FreqaiExampleStrategy.py:287: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> bytes- freqtrade/templates/FreqaiExampleStrategy.py:287: error: Invalid index type "str" for "str"; expected type "SupportsIndex | slice[Any, Any, Any]" [index]+ freqtrade/templates/FreqaiExampleStrategy.py:287: error: Invalid index type "str" for "str"; expected type "SupportsIndex | slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None]" [index]- freqtrade/templates/FreqaiExampleStrategy.py:290: note: def __getitem__(self, slice[Any, Any, Any], /) -> bytes+ freqtrade/templates/FreqaiExampleStrategy.py:290: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> bytes- freqtrade/templates/FreqaiExampleStrategy.py:290: error: Invalid index type "str" for "str"; expected type "SupportsIndex | slice[Any, Any, Any]" [index]+ freqtrade/templates/FreqaiExampleStrategy.py:290: error: Invalid index type "str" for "str"; expected type "SupportsIndex | slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None]" [index] |
hauntsaninja
commented
Feb 23, 2026
Thanks for getting this one over the line! :-) |
Uh oh!
There was an error while loading. Please reload this page.
This non-overlapping container check should probably generally be restricted to builtin types with known classAccept(ImmutableList[tuple[str, float]]):and then flags (source) # check __contains__assert"sailor"inacceptassert"spy"notinacceptbecause it thinks its a def__contains__(self, value: str) ->bool: # type: ignore[override]foritem, _qualityinself:
ifself._value_matches(value, item):
returnTruereturnFalseSo actually, structurally it's a This also indicates something else: when a method uses |
Yeah, makes sense. I'm okay with restricting the check, but as it stands it's a useful feature of mypy that hasn't elicited many complaints, so we can't have it be broken. I think ty folks were recently debating how to handle the interaction between nominal and substructural typing, could be interesting to see where they landed. |
Source commit:
python/typeshed@637ece0