-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Replace plain slice
type hints with IndexSlice
.
#13007
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
This seems like a good improvement to me. I imagine this would be very nice for replacing mypy's hardcoded It looks like the pytype errors may be due to pytype having its own builtins stubs, which don't define |
Diff from mypy_primer, showing the effect of this PR on open source code: streamlit (https://github.com/streamlit/streamlit)
- lib/tests/streamlit/elements/lib/column_config_utils_test.py:385:13: note: def __getitem__(self, Union[SupportsIndex, slice[Any, Any, Any]], /) -> str
+ lib/tests/streamlit/elements/lib/column_config_utils_test.py:385:13: note: def __getitem__(self, Union[SupportsIndex, slice[Optional[SupportsIndex], Optional[SupportsIndex], Optional[SupportsIndex]]], /) -> str
- lib/tests/streamlit/runtime/state/query_params_test.py:264:37: note: def __getitem__(self, slice[Any, Any, Any], /) -> Tuple[Any, ...]
+ lib/tests/streamlit/runtime/state/query_params_test.py:264:37: note: def __getitem__(self, slice[Optional[SupportsIndex], Optional[SupportsIndex], Optional[SupportsIndex]], /) -> Tuple[Any, ...]
prefect (https://github.com/PrefectHQ/prefect)
- src/prefect/cli/deploy.py:1144: note: def __setitem__(self, slice[Any, Any, Any], Iterable[dict[Any, Any]], /) -> None
+ src/prefect/cli/deploy.py:1144: note: def __setitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], Iterable[dict[Any, Any]], /) -> None
- src/prefect/cli/deploy.py:1170: note: def __setitem__(self, slice[Any, Any, Any], Iterable[dict[Any, Any]], /) -> None
+ src/prefect/cli/deploy.py:1170: note: def __setitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], Iterable[dict[Any, Any]], /) -> None
- src/prefect/cli/deploy.py:1178: note: def __setitem__(self, slice[Any, Any, Any], Iterable[dict[Any, Any]], /) -> None
+ src/prefect/cli/deploy.py:1178: note: def __setitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], Iterable[dict[Any, Any]], /) -> None
- src/prefect/cli/deploy.py:1195: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[dict[Any, Any]]
+ src/prefect/cli/deploy.py:1195: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[dict[Any, Any]]
speedrun.com_global_scoreboard_webapp (https://github.com/Avasam/speedrun.com_global_scoreboard_webapp)
- backend/api/tournament_scheduler_api.py:327: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[Any]
+ backend/api/tournament_scheduler_api.py:327: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[Any]
- backend/api/tournament_scheduler_api.py:331: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[Any]
+ backend/api/tournament_scheduler_api.py:331: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[Any]
- backend/api/tournament_scheduler_api.py:335: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[Any]
+ backend/api/tournament_scheduler_api.py:335: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[Any]
operator (https://github.com/canonical/operator)
- ops/framework.py:1304: note: def __getitem__(self, slice[Any, Any, Any], /) -> MutableSequence[Any]
+ ops/framework.py:1304: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> MutableSequence[Any]
- ops/framework.py:1304: note: def __getitem__(self, slice[Any, Any, Any], /) -> Sequence[Any]
+ ops/framework.py:1304: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> Sequence[Any]
- ops/framework.py:1307: note: def __setitem__(self, slice[Any, Any, Any], Iterable[Any], /) -> None
+ ops/framework.py:1307: note: def __setitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], Iterable[Any], /) -> None
- ops/framework.py:1311: note: def __delitem__(self, slice[Any, Any, Any], /) -> None
+ ops/framework.py:1311: note: def __delitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> None
discord.py (https://github.com/Rapptz/discord.py)
- discord/http.py:235: note: def __setitem__(self, slice[Any, Any, Any], Iterable[Embed], /) -> None
+ discord/http.py:235: note: def __setitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], Iterable[Embed], /) -> None
dd-trace-py (https://github.com/DataDog/dd-trace-py)
- ddtrace/settings/config.py:905: note: def __getitem__(self, SupportsIndex | slice[Any, Any, Any], /) -> str
+ ddtrace/settings/config.py:905: note: def __getitem__(self, SupportsIndex | slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> str
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]
|
Closing in favor of #13008. |
@srittau This PR is not in conflict with #13008, it is for making some annotations in the stubs more precise by replacing Thanks to #13008, one could now use |
Trying to see what happens when we replace
slice
type hints withannotations.