draft: simplify slice overloads#15536
Draft
randolf-scholz wants to merge 1 commit intopython:mainfrom
Draft
Conversation
ddd59ca to
dfe973b
Compare
Contributor
|
Diff from mypy_primer, showing the effect of this PR on open source code: kornia (https://github.com/kornia/kornia)
+ kornia/geometry/subpix/nms.py:135: error: Argument 2 to "slice" has incompatible type "int"; expected "None" [arg-type]
+ kornia/models/sam/architecture/mask_decoder.py:112: error: Argument 2 to "slice" has incompatible type "int"; expected "None" [arg-type]
freqtrade (https://github.com/freqtrade/freqtrade)
+ freqtrade/exchange/exchange.py:3341: error: Argument 1 to "slice" has incompatible type "None"; expected "int" [arg-type]
xarray (https://github.com/pydata/xarray)
+ xarray/core/dataset.py: note: In member "tail" of class "Dataset":
+ xarray/core/dataset.py:3227: error: Argument 1 to "slice" has incompatible type "int"; expected "None" [arg-type]
+ xarray/core/dataset.py: note: In member "diff" of class "Dataset":
+ xarray/core/dataset.py:7870: error: Incompatible types in assignment (expression has type "dict[Hashable, slice[None, int, None]]", variable has type "dict[Hashable, slice[int, None, None]]") [assignment]
+ xarray/computation/rolling.py: note: In member "_numbagg_reduce" of class "DataArrayRolling":
+ xarray/computation/rolling.py:624: error: Argument 1 to "slice" has incompatible type "int"; expected "None" [arg-type]
+ xarray/computation/rolling.py: note: In member "_bottleneck_reduce" of class "DataArrayRolling":
+ xarray/computation/rolling.py:669: error: Argument 1 to "slice" has incompatible type "int"; expected "None" [arg-type]
+ xarray/tests/test_backends.py: note: In member "test_write_region_mode" of class "ZarrBase":
+ xarray/tests/test_backends.py:3520: error: No overload variant of "to_zarr" of "Dataset" matches argument types "Any", "object", "Any", "dict[str, Any]" [call-overload]
+ xarray/tests/test_backends.py:3520: note: Possible overload variants:
+ xarray/tests/test_backends.py:3520: note: def to_zarr(self, store: Any | None = ..., chunk_store: MutableMapping[Any, Any] | str | PathLike[Any] | None = ..., mode: Literal['w', 'w-', 'a', 'a-', 'r+', 'r'] | None = ..., synchronizer: Any = ..., group: str | None = ..., encoding: Mapping[Any, Any] | None = ..., *, compute: Literal[True] = ..., consolidated: bool | None = ..., append_dim: Hashable | None = ..., region: Mapping[str, slice[Any, Any, Any] | Literal['auto']] | Literal['auto'] | None = ..., safe_chunks: bool = ..., align_chunks: bool = ..., storage_options: dict[str, str] | None = ..., zarr_version: int | None = ..., zarr_format: int | None = ..., write_empty_chunks: bool | None = ..., chunkmanager_store_kwargs: dict[str, Any] | None = ...) -> ZarrStore
+ xarray/tests/test_backends.py:3520: note: def to_zarr(self, store: Any | None = ..., chunk_store: MutableMapping[Any, Any] | str | PathLike[Any] | None = ..., mode: Literal['w', 'w-', 'a', 'a-', 'r+', 'r'] | None = ..., synchronizer: Any = ..., group: str | None = ..., encoding: Mapping[Any, Any] | None = ..., *, compute: Literal[False], consolidated: bool | None = ..., append_dim: Hashable | None = ..., region: Mapping[str, slice[Any, Any, Any] | Literal['auto']] | Literal['auto'] | None = ..., safe_chunks: bool = ..., align_chunks: bool = ..., storage_options: dict[str, str] | None = ..., zarr_version: int | None = ..., zarr_format: int | None = ..., write_empty_chunks: bool | None = ..., chunkmanager_store_kwargs: dict[str, Any] | None = ...) -> Any
+ xarray/tests/test_backends.py:3520: error: Argument 1 to "isel" of "Dataset" has incompatible type "object"; expected "Mapping[Any, Any] | None" [arg-type]
static-frame (https://github.com/static-frame/static-frame)
+ static_frame/core/node_selector.py:828: error: Argument 2 to "slice" has incompatible type "int"; expected "None" [arg-type]
+ static_frame/core/type_blocks.py:3665: error: Argument 2 to "slice" has incompatible type "None"; expected "int" [arg-type]
+ static_frame/core/type_blocks.py:3667: error: Incompatible types in assignment (expression has type "slice[None, None, None]", variable has type "slice[int, int, None]") [assignment]
+ static_frame/core/type_blocks.py:3741: error: Argument 2 to "slice" has incompatible type "None"; expected "int" [arg-type]
+ static_frame/core/type_blocks.py:3743: error: Incompatible types in assignment (expression has type "slice[None, None, None]", variable has type "slice[int, int, None]") [assignment]
+ static_frame/core/type_blocks.py:4023: error: Argument 2 to "slice" has incompatible type "None"; expected "int" [arg-type]
+ static_frame/core/series.py:1714: error: Argument 2 to "slice" has incompatible type "None"; expected "int" [arg-type]
+ static_frame/core/series.py:1716: error: Incompatible types in assignment (expression has type "slice[None, None, None]", variable has type "slice[int, int, None]") [assignment]
+ static_frame/core/quilt.py:170: error: Incompatible types in assignment (expression has type "IndexBase", target has type "Index[Any] | TTreeNode") [assignment]
pandas (https://github.com/pandas-dev/pandas)
+ pandas/core/array_algos/transforms.py:39: error: Argument 2 to "slice" has incompatible type "int"; expected "None" [arg-type]
+ pandas/core/array_algos/transforms.py:41: error: Argument 1 to "slice" has incompatible type "int"; expected "None" [arg-type]
+ pandas/core/algorithms.py:1396: error: Argument 2 to "slice" has incompatible type "int | integer[Any]"; expected "None" [arg-type]
+ pandas/core/algorithms.py:1396: error: Argument 1 to "slice" has incompatible type "int | integer[Any]"; expected "None" [arg-type]
+ pandas/core/algorithms.py:1396: error: Argument 2 to "slice" has incompatible type "None"; expected "int | integer[Any]" [arg-type]
+ pandas/core/algorithms.py:1407: error: Argument 1 to "slice" has incompatible type "int | integer[Any]"; expected "None" [arg-type]
+ pandas/core/algorithms.py:1407: error: Argument 1 to "slice" has incompatible type "None"; expected "int | integer[Any]" [arg-type]
+ pandas/core/algorithms.py:1407: error: Argument 2 to "slice" has incompatible type "int | integer[Any]"; expected "None" [arg-type]
+ pandas/core/algorithms.py:1411: error: Argument 2 to "slice" has incompatible type "int | integer[Any]"; expected "None" [arg-type]
+ pandas/core/algorithms.py:1411: error: Argument 1 to "slice" has incompatible type "int | integer[Any]"; expected "None" [arg-type]
+ pandas/core/algorithms.py:1411: error: Argument 2 to "slice" has incompatible type "None"; expected "int | integer[Any]" [arg-type]
scipy (https://github.com/scipy/scipy)
+ scipy/optimize/_isotonic.py:124: error: Argument 3 to "slice" has incompatible type "int"; expected "None" [arg-type]
jax (https://github.com/google/jax)
+ jax/_src/numpy/lax_numpy.py:573: error: Argument 3 to "slice" has incompatible type "int"; expected "None" [arg-type]
+ jax/_src/numpy/lax_numpy.py:1662: error: Argument 1 to "slice" has incompatible type "int"; expected "None" [arg-type]
+ jax/_src/numpy/lax_numpy.py:1663: error: Argument 2 to "slice" has incompatible type "int"; expected "None" [arg-type]
+ jax/experimental/sparse/bcoo.py:1999: error: Argument 1 to "slice" has incompatible type "int"; expected "None" [arg-type]
+ jax/experimental/sparse/bcoo.py:1999: error: Argument 2 to "slice" has incompatible type "int"; expected "None" [arg-type]
+ jax/experimental/sparse/bcoo.py:1999: error: Argument 3 to "slice" has incompatible type "int"; expected "None" [arg-type]
+ jax/experimental/sparse/bcoo.py:2000: error: Argument 1 to "slice" has incompatible type "int"; expected "None" [arg-type]
+ jax/experimental/sparse/bcoo.py:2000: error: Argument 2 to "slice" has incompatible type "int"; expected "None" [arg-type]
+ jax/experimental/sparse/bcoo.py:2000: error: Argument 3 to "slice" has incompatible type "int"; expected "None" [arg-type]
+ jax/experimental/sparse/bcoo.py:2004: error: Argument 1 to "slice" has incompatible type "int"; expected "None" [arg-type]
+ jax/experimental/sparse/bcoo.py:2004: error: Argument 2 to "slice" has incompatible type "int"; expected "None" [arg-type]
+ jax/experimental/sparse/bcoo.py:2004: error: Argument 3 to "slice" has incompatible type "int"; expected "None" [arg-type]
+ jax/experimental/mosaic/gpu/launch_context.py:199: error: Argument 1 to "slice" has incompatible type "int"; expected "None" [arg-type]
+ jax/experimental/mosaic/gpu/fragmented_array.py:3940: error: Argument 1 to "slice" has incompatible type "None"; expected "int" [arg-type]
aiohttp (https://github.com/aio-libs/aiohttp)
+ aiohttp/web_request.py:599:22: error: Argument 1 to "slice" has incompatible type "Any | None"; expected "int" [arg-type]
+ aiohttp/web_request.py:599:29: error: Argument 2 to "slice" has incompatible type "Any | None"; expected "int" [arg-type]
|
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.
This drops the "None as Any" assumption in the
slice.__new__overloads, fixing #15526.