-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Replace plain slice
type hints with IndexSlice
.
#13007
base: main
Are you sure you want to change the base?
Conversation
Diff from mypy_primer, showing the effect of this PR on open source code: prefect (https://github.com/PrefectHQ/prefect)
- src/prefect/utilities/annotations.py:41: note: def __getitem__(self, slice[Any, Any, Any], /) -> tuple[Never, ...]
+ src/prefect/utilities/annotations.py:41: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> tuple[Never, ...]
- src/prefect/utilities/annotations.py:41: note: def __getitem__(self, slice[Any, Any, Any], /) -> Sequence[Never]
+ src/prefect/utilities/annotations.py:41: note: def __getitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> Sequence[Never]
- src/prefect/cli/cloud/__init__.py:326: note: def __getitem__(self, SupportsIndex | slice[Any, Any, Any], /) -> str
+ src/prefect/cli/cloud/__init__.py:326: note: def __getitem__(self, SupportsIndex | slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> str
- src/prefect/cli/deploy.py:1127: note: def __setitem__(self, slice[Any, Any, Any], Iterable[dict[Any, Any]], /) -> None
+ src/prefect/cli/deploy.py:1127: note: def __setitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], Iterable[dict[Any, Any]], /) -> None
- src/prefect/cli/deploy.py:1153: note: def __setitem__(self, slice[Any, Any, Any], Iterable[dict[Any, Any]], /) -> None
+ src/prefect/cli/deploy.py:1153: note: def __setitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], Iterable[dict[Any, Any]], /) -> None
- src/prefect/cli/deploy.py:1161: note: def __setitem__(self, slice[Any, Any, Any], Iterable[dict[Any, Any]], /) -> None
+ src/prefect/cli/deploy.py:1161: note: def __setitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], Iterable[dict[Any, Any]], /) -> None
- src/prefect/cli/deploy.py:1178: note: def __getitem__(self, slice[Any, Any, Any], /) -> list[dict[Any, Any]]
+ src/prefect/cli/deploy.py:1178: 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]
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, ...]
discord.py (https://github.com/Rapptz/discord.py)
- discord/http.py:234: note: def __setitem__(self, slice[Any, Any, Any], Iterable[Embed], /) -> None
+ discord/http.py:234: note: def __setitem__(self, slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], Iterable[Embed], /) -> None
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
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]
dd-trace-py (https://github.com/DataDog/dd-trace-py)
- ddtrace/settings/config.py:904: note: def __getitem__(self, SupportsIndex | slice[Any, Any, Any], /) -> str
+ ddtrace/settings/config.py:904: note: def __getitem__(self, SupportsIndex | slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> str
|
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 |
Trying to see what happens when we replace
slice
type hints withannotations.