Repository navigation
Conversation
Keep `float` in the following cases:
- If it's already in an union with `int`.
- Return types (also in compound return types).
- Return types of `Callable` types.
- Type arguments of base classes.
- Type var constraints.
This was mainly generated using a codemod, and manually verified.
Manual changes:
- Reordered `float`/`int` unions to a consistent order.
- Change a few instances of `FloatInt` to `float | int`.
- `statistics._Number`
- Change a few instances of `FloatInt` to `float`:
- `time._SupportsFloatOrIndex` (is in union with `SupportsIndex`)
- Add `int` to constraints of `statistics._NumberT`.
- Remove `# noqa: Y041` comments.
- Update/remove a few outdated comments.
Part of python#16059
This comment has been minimized.
This comment has been minimized.
3 of 7 tasks
Contributor
|
Diff from mypy_primer, showing the effect of this PR on open source code: prefect (https://github.com/PrefectHQ/prefect)
- src/prefect/runner/_scheduled_run_poller.py:187: error: Argument "seconds" to "timedelta" has incompatible type "int | None"; expected "float" [arg-type]
+ src/prefect/runner/_scheduled_run_poller.py:187: error: Argument "seconds" to "timedelta" has incompatible type "int | None"; expected "float | int" [arg-type]
materialize (https://github.com/MaterializeInc/materialize)
- misc/python/materialize/scratch.py:113: note: def [_TzInfoT: tzinfo | None] fromtimestamp(cls, timestamp: float, tz: None = ...) -> datetime[None]
+ misc/python/materialize/scratch.py:113: note: def [_TzInfoT: tzinfo | None] fromtimestamp(cls, timestamp: float | int, tz: None = ...) -> datetime[None]
- misc/python/materialize/scratch.py:113: note: def [_TzInfoT: tzinfo | None] fromtimestamp(cls, timestamp: float, tz: tzinfo) -> datetime[tzinfo]
+ misc/python/materialize/scratch.py:113: note: def [_TzInfoT: tzinfo | None] fromtimestamp(cls, timestamp: float | int, tz: tzinfo) -> datetime[tzinfo]
- misc/python/materialize/scratch.py:113: note: def [_TzInfoT: tzinfo | None] fromtimestamp(cls, timestamp: float, tz: tzinfo | None) -> datetime[tzinfo] | datetime[None]
+ misc/python/materialize/scratch.py:113: note: def [_TzInfoT: tzinfo | None] fromtimestamp(cls, timestamp: float | int, tz: tzinfo | None) -> datetime[tzinfo] | datetime[None]
ibis (https://github.com/ibis-project/ibis)
- ibis/common/temporal.py:196: error: Argument 1 to "Decimal" has incompatible type "Real"; expected "Decimal | float | str | tuple[int, Sequence[int], int]" [arg-type]
+ ibis/common/temporal.py:196: error: Argument 1 to "Decimal" has incompatible type "Real"; expected "Decimal | float | int | str | tuple[int, Sequence[int], int]" [arg-type]
jax (https://github.com/google/jax)
- jax/_src/numpy/indexing.py:370: error: Incompatible types in assignment (expression has type "Array | ndarray[tuple[Any, ...], dtype[Any]] | Any | int | float | complex", variable has type "int | integer[Any] | slice[Any, Any, Any] | EllipsisType | Sequence[int | integer[Any]] | Array | ndarray[tuple[Any, ...], dtype[Any]] | None") [assignment]
+ jax/_src/numpy/indexing.py:370: error: Incompatible types in assignment (expression has type "Array | ndarray[tuple[Any, ...], dtype[Any]] | signedinteger[_32Bit | _64Bit] | Any | int | float | complex", variable has type "int | integer[Any] | slice[Any, Any, Any] | EllipsisType | Sequence[int | integer[Any]] | Array | ndarray[tuple[Any, ...], dtype[Any]] | None") [assignment]
pytensor (https://github.com/pymc-devs/pytensor)
- pytensor/tensor/extra_ops.py:1791: note: def __pow__(self, float, None = ..., /) -> Any
+ pytensor/tensor/extra_ops.py:1791: note: def __pow__(self, float | int, None = ..., /) -> Any
- pytensor/tensor/extra_ops.py:1867: note: def __pow__(self, float, None = ..., /) -> Any
+ pytensor/tensor/extra_ops.py:1867: note: def __pow__(self, float | int, None = ..., /) -> Any
|
Collaborator
Author
|
Primer output is purely cosmetic. |
This branch has not been deployed
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.
Keep
floatin the following cases:int.Callabletypes.This was mainly generated using a codemod, and manually verified. Manual changes:
float/intunions to a consistent order.FloatInttofloat | int.statistics._NumberFloatInttofloat:time._SupportsFloatOrIndex(is in union withSupportsIndex)builtins.pow(intis handled in earlier overloads, prevents overlapping overloads warning)fractions(same reason)intto constraints ofstatistics._NumberT.# noqa: Y041comments.Part of #16059