-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Changed union creation logic to retain (rather than elide) redundant … #8396
Merged
Conversation
This file contains 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
…literals in some cases. In particular, for type expressions that explicitly include literals along with their non-literal counterpart like `Literal[1] | int`. Retaining these redundant subtypes can be useful for language server features like completion suggestions. This addresses #8392.
Diff from mypy_primer, showing the effect of this PR on open source code: xarray (https://github.com/pydata/xarray)
- /tmp/mypy_primer/projects/xarray/asv_bench/benchmarks/dataset_io.py:385:59 - error: Argument of type "dict[str, float]" cannot be assigned to parameter "chunks" of type "str | int | tuple[int, ...] | Mapping[Any, T_ChunkDim] | None" in function "open_mfdataset"
+ /tmp/mypy_primer/projects/xarray/asv_bench/benchmarks/dataset_io.py:385:59 - error: Argument of type "dict[str, float]" cannot be assigned to parameter "chunks" of type "T_Chunks" in function "open_mfdataset"
- Type "dict[str, float]" is incompatible with type "str | int | tuple[int, ...] | Mapping[Any, T_ChunkDim] | None"
+ Type "dict[str, float]" is incompatible with type "T_Chunks"
- /tmp/mypy_primer/projects/xarray/asv_bench/benchmarks/dataset_io.py:391:63 - error: Argument of type "dict[str, float]" cannot be assigned to parameter "chunks" of type "str | int | tuple[int, ...] | Mapping[Any, T_ChunkDim] | None" in function "open_mfdataset"
+ /tmp/mypy_primer/projects/xarray/asv_bench/benchmarks/dataset_io.py:391:63 - error: Argument of type "dict[str, float]" cannot be assigned to parameter "chunks" of type "T_Chunks" in function "open_mfdataset"
- Type "dict[str, float]" is incompatible with type "str | int | tuple[int, ...] | Mapping[Any, T_ChunkDim] | None"
+ Type "dict[str, float]" is incompatible with type "T_Chunks"
- /tmp/mypy_primer/projects/xarray/asv_bench/benchmarks/dataset_io.py:407:59 - error: Argument of type "dict[str, float]" cannot be assigned to parameter "chunks" of type "str | int | tuple[int, ...] | Mapping[Any, T_ChunkDim] | None" in function "open_mfdataset"
+ /tmp/mypy_primer/projects/xarray/asv_bench/benchmarks/dataset_io.py:407:59 - error: Argument of type "dict[str, float]" cannot be assigned to parameter "chunks" of type "T_Chunks" in function "open_mfdataset"
- Type "dict[str, float]" is incompatible with type "str | int | tuple[int, ...] | Mapping[Any, T_ChunkDim] | None"
+ Type "dict[str, float]" is incompatible with type "T_Chunks"
- /tmp/mypy_primer/projects/xarray/asv_bench/benchmarks/dataset_io.py:413:63 - error: Argument of type "dict[str, float]" cannot be assigned to parameter "chunks" of type "str | int | tuple[int, ...] | Mapping[Any, T_ChunkDim] | None" in function "open_mfdataset"
+ /tmp/mypy_primer/projects/xarray/asv_bench/benchmarks/dataset_io.py:413:63 - error: Argument of type "dict[str, float]" cannot be assigned to parameter "chunks" of type "T_Chunks" in function "open_mfdataset"
- Type "dict[str, float]" is incompatible with type "str | int | tuple[int, ...] | Mapping[Any, T_ChunkDim] | None"
+ Type "dict[str, float]" is incompatible with type "T_Chunks"
- /tmp/mypy_primer/projects/xarray/asv_bench/benchmarks/dataset_io.py:443:61 - error: Argument of type "dict[str, float]" cannot be assigned to parameter "chunks" of type "str | int | tuple[int, ...] | Mapping[Any, T_ChunkDim] | None" in function "open_mfdataset"
+ /tmp/mypy_primer/projects/xarray/asv_bench/benchmarks/dataset_io.py:443:61 - error: Argument of type "dict[str, float]" cannot be assigned to parameter "chunks" of type "T_Chunks" in function "open_mfdataset"
- Type "dict[str, float]" is incompatible with type "str | int | tuple[int, ...] | Mapping[Any, T_ChunkDim] | None"
+ Type "dict[str, float]" is incompatible with type "T_Chunks"
- /tmp/mypy_primer/projects/xarray/asv_bench/benchmarks/dataset_io.py:455:61 - error: Argument of type "dict[str, float]" cannot be assigned to parameter "chunks" of type "str | int | tuple[int, ...] | Mapping[Any, T_ChunkDim] | None" in function "open_mfdataset"
+ /tmp/mypy_primer/projects/xarray/asv_bench/benchmarks/dataset_io.py:455:61 - error: Argument of type "dict[str, float]" cannot be assigned to parameter "chunks" of type "T_Chunks" in function "open_mfdataset"
- Type "dict[str, float]" is incompatible with type "str | int | tuple[int, ...] | Mapping[Any, T_ChunkDim] | None"
+ Type "dict[str, float]" is incompatible with type "T_Chunks"
bokeh (https://github.com/bokeh/bokeh)
+ "Nullable[Any]" is incompatible with "None"
- "Nullable[Any]" is incompatible with "None" (reportArgumentType)
+ "Nullable[Any]" is incompatible with type "Auto" (reportArgumentType)
+ "Nullable[Any]" is incompatible with "None"
- "Nullable[Any]" is incompatible with "None" (reportArgumentType)
+ "Nullable[Any]" is incompatible with type "Auto" (reportArgumentType)
+ "Nullable[Any]" is incompatible with "None"
- "Nullable[Any]" is incompatible with "None" (reportArgumentType)
+ "Nullable[Any]" is incompatible with type "Auto" (reportArgumentType)
+ "Nullable[Any]" is incompatible with "None"
- "Nullable[Any]" is incompatible with "None" (reportArgumentType)
+ "Nullable[Any]" is incompatible with type "Auto" (reportArgumentType)
+ "Nullable[Any]" is incompatible with "None"
- "Nullable[Any]" is incompatible with "None" (reportArgumentType)
+ "Nullable[Any]" is incompatible with type "Auto" (reportArgumentType)
+ "Nullable[Any]" is incompatible with "None"
- "Nullable[Any]" is incompatible with "None" (reportArgumentType)
+ "Nullable[Any]" is incompatible with type "Auto" (reportArgumentType)
+ "Nullable[Any]" is incompatible with "None"
- "Nullable[Any]" is incompatible with "None" (reportArgumentType)
+ "Nullable[Any]" is incompatible with type "Auto" (reportArgumentType)
+ "Nullable[Any]" is incompatible with "None"
- "Nullable[Any]" is incompatible with "None" (reportArgumentType)
+ "Nullable[Any]" is incompatible with type "Auto" (reportArgumentType)
+ "Nullable[Any]" is incompatible with "None"
- "Nullable[Any]" is incompatible with "None" (reportArgumentType)
+ "Nullable[Any]" is incompatible with type "Auto" (reportArgumentType)
+ "Nullable[Any]" is incompatible with "None"
- "Nullable[Any]" is incompatible with "None" (reportArgumentType)
+ "Nullable[Any]" is incompatible with type "Auto" (reportArgumentType)
Tanjun (https://github.com/FasterSpeeding/Tanjun)
- Parameter type is "Unknown | str" (reportUnknownParameterType)
+ Parameter type is "Unknown | str | Literal['ok']" (reportUnknownParameterType)
- Type of "result" is "(event: Unknown | str) -> Coroutine[Any, Any, None]" (reportUnknownVariableType)
+ Type of "result" is "(event: Unknown | str | Literal['ok']) -> Coroutine[Any, Any, None]" (reportUnknownVariableType)
- Argument type is "(event: Unknown | str) -> Coroutine[Any, Any, None]" (reportUnknownArgumentType)
+ Argument type is "(event: Unknown | str | Literal['ok']) -> Coroutine[Any, Any, None]" (reportUnknownArgumentType)
- Parameter type is "Unknown | str" (reportUnknownParameterType)
+ Parameter type is "Unknown | str | Literal['ok']" (reportUnknownParameterType)
- Type of "result" is "(event: Unknown | str) -> Coroutine[Any, Any, None]" (reportUnknownVariableType)
+ Type of "result" is "(event: Unknown | str | Literal['ok']) -> Coroutine[Any, Any, None]" (reportUnknownVariableType)
- Argument type is "(event: Unknown | str) -> Coroutine[Any, Any, None]" (reportUnknownArgumentType)
+ Argument type is "(event: Unknown | str | Literal['ok']) -> Coroutine[Any, Any, None]" (reportUnknownArgumentType)
- Parameter type is "Unknown | str" (reportUnknownParameterType)
+ Parameter type is "Unknown | str | Literal['ok']" (reportUnknownParameterType)
- Type of "result" is "(event: Unknown | str) -> Coroutine[Any, Any, None]" (reportUnknownVariableType)
+ Type of "result" is "(event: Unknown | str | Literal['ok']) -> Coroutine[Any, Any, None]" (reportUnknownVariableType)
- Argument type is "(event: Unknown | str) -> Coroutine[Any, Any, None]" (reportUnknownArgumentType)
+ Argument type is "(event: Unknown | str | Literal['ok']) -> Coroutine[Any, Any, None]" (reportUnknownArgumentType)
- Parameter type is "Unknown | str" (reportUnknownParameterType)
+ Parameter type is "Unknown | str | Literal['ok']" (reportUnknownParameterType)
- Type of "result" is "(event: Unknown | str) -> Coroutine[Any, Any, None]" (reportUnknownVariableType)
+ Type of "result" is "(event: Unknown | str | Literal['ok']) -> Coroutine[Any, Any, None]" (reportUnknownVariableType)
- Argument type is "(event: Unknown | str) -> Coroutine[Any, Any, None]" (reportUnknownArgumentType)
+ Argument type is "(event: Unknown | str | Literal['ok']) -> Coroutine[Any, Any, None]" (reportUnknownArgumentType)
|
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.
…literals in some cases. In particular, for type expressions that explicitly include literals along with their non-literal counterpart like
Literal[1] | int
. Retaining these redundant subtypes can be useful for language server features like completion suggestions. This addresses #8392.