Skip to content

[stubs] Replace float with FloatInt - #16789

Open
srittau wants to merge 12 commits into
python:mainfrom
srittau:float-int-stubs
Open

srittau wants to merge 12 commits into
python:mainfrom
srittau:float-int-stubs

Conversation

@srittau

@srittau srittau commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

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.
  • As base class.
  • Type arguments of base classes.
  • Type var constraints.
  • Auto-generated protobuf stubs that use builtins.float – the generator needs an update.

This was mainly generated using a codemod, and manually verified. Manual changes:

  • Reordered float/int unions to a consistent order.
  • Replace all instances in openpyxl, since the stubs do overloads based on int/`float.
  • Change a few instances of FloatInt to float:
    • convertdate.utils (same)

Part of #16059

@srittau srittau mentioned this pull request Nov 13, 2026
3 of 7 tasks
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

1 similar comment
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@srittau
srittau marked this pull request as ready for review November 13, 2026 17:04
@srittau
srittau requested review from Akuli and Avasam as code owners November 13, 2026 17:04
@srittau

srittau commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator Author

Primer reports just spam.

@github-actions

Copy link
Copy Markdown
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

paroxython (https://github.com/laowantong/paroxython)
- paroxython/parse_program.py:240: error: Incompatible types in assignment (expression has type "Callable[[str, int | None, int | None, bool, bool | None, bool, float | None], Scanner[str]]", target has type "Pattern[Any]")  [assignment]
+ paroxython/parse_program.py:240: error: Incompatible types in assignment (expression has type "Callable[[str, int | None, int | None, bool, bool | None, bool, float | int | None], Scanner[str]]", target has type "Pattern[Any]")  [assignment]

apprise (https://github.com/caronc/apprise)
- apprise/plugins/amqp/v091.py:132: error: Argument 1 to "ConnectionParameters" has incompatible type "**dict[str, object]"; expected "float"  [arg-type]
- apprise/plugins/amqp/v091.py:132: error: Argument 1 to "ConnectionParameters" has incompatible type "**dict[str, object]"; expected "float | None"  [arg-type]
+ apprise/plugins/amqp/v091.py:132: error: Argument 1 to "ConnectionParameters" has incompatible type "**dict[str, object]"; expected "float | int"  [arg-type]
+ apprise/plugins/amqp/v091.py:132: error: Argument 1 to "ConnectionParameters" has incompatible type "**dict[str, object]"; expected "float | int | None"  [arg-type]

rclip (https://github.com/yurijmikhalevich/rclip)
- rclip/utils/download_progress.py:21: note:     def __init__(self, iterable: Iterable[Any], desc: str | None = ..., total: float | None = ..., leave: bool | None = ..., file: SupportsWrite[str] | None = ..., ncols: int | None = ..., mininterval: float = ..., maxinterval: float = ..., miniters: float | None = ..., ascii: bool | str | None = ..., disable: bool | None = ..., unit: str = ..., unit_scale: bool | float = ..., dynamic_ncols: bool = ..., smoothing: float = ..., bar_format: str | None = ..., initial: float = ..., position: int | None = ..., postfix: Mapping[str, object] | str | None = ..., unit_divisor: float = ..., write_bytes: bool = ..., lock_args: tuple[bool | None, float | None] | tuple[bool | None] | None = ..., nrows: int | None = ..., colour: str | None = ..., delay: float | None = ..., gui: bool = ..., **kwargs: Any) -> None
+ rclip/utils/download_progress.py:21: note:     def __init__(self, iterable: Iterable[Any], desc: str | None = ..., total: float | int | None = ..., leave: bool | None = ..., file: SupportsWrite[str] | None = ..., ncols: int | None = ..., mininterval: float | int = ..., maxinterval: float | int = ..., miniters: float | int | None = ..., ascii: bool | str | None = ..., disable: bool | None = ..., unit: str = ..., unit_scale: bool | float | int = ..., dynamic_ncols: bool = ..., smoothing: float | int = ..., bar_format: str | None = ..., initial: float | int = ..., position: int | None = ..., postfix: Mapping[str, object] | str | None = ..., unit_divisor: float | int = ..., write_bytes: bool = ..., lock_args: tuple[bool | None, float | int | None] | tuple[bool | None] | None = ..., nrows: int | None = ..., colour: str | None = ..., delay: float | int | None = ..., gui: bool = ..., **kwargs: Any) -> None
- rclip/utils/download_progress.py:21: note:     def __init__(self, iterable: None = ..., desc: str | None = ..., total: float | None = ..., leave: bool | None = ..., file: SupportsWrite[str] | None = ..., ncols: int | None = ..., mininterval: float = ..., maxinterval: float = ..., miniters: float | None = ..., ascii: bool | str | None = ..., disable: bool | None = ..., unit: str = ..., unit_scale: bool | float = ..., dynamic_ncols: bool = ..., smoothing: float = ..., bar_format: str | None = ..., initial: float = ..., position: int | None = ..., postfix: Mapping[str, object] | str | None = ..., unit_divisor: float = ..., write_bytes: bool | None = ..., lock_args: tuple[bool | None, float | None] | tuple[bool | None] | None = ..., nrows: int | None = ..., colour: str | None = ..., delay: float | None = ..., gui: bool = ..., **kwargs: Any) -> None
+ rclip/utils/download_progress.py:21: note:     def __init__(self, iterable: None = ..., desc: str | None = ..., total: float | int | None = ..., leave: bool | None = ..., file: SupportsWrite[str] | None = ..., ncols: int | None = ..., mininterval: float | int = ..., maxinterval: float | int = ..., miniters: float | int | None = ..., ascii: bool | str | None = ..., disable: bool | None = ..., unit: str = ..., unit_scale: bool | float | int = ..., dynamic_ncols: bool = ..., smoothing: float | int = ..., bar_format: str | None = ..., initial: float | int = ..., position: int | None = ..., postfix: Mapping[str, object] | str | None = ..., unit_divisor: float | int = ..., write_bytes: bool | None = ..., lock_args: tuple[bool | None, float | int | None] | tuple[bool | None] | None = ..., nrows: int | None = ..., colour: str | None = ..., delay: float | int | None = ..., gui: bool = ..., **kwargs: Any) -> None

dd-trace-py (https://github.com/DataDog/dd-trace-py)
- ddtrace/profiling/_gevent.py:218: note:          def spawn_later(cls, seconds: float, run: def (*Any, **Any) -> Any, *args: Any, **kwargs: Any) -> Greenlet
+ ddtrace/profiling/_gevent.py:218: note:          def spawn_later(cls, seconds: float | int, run: def (*Any, **Any) -> Any, *args: Any, **kwargs: Any) -> Greenlet
- ddtrace/profiling/_gevent.py:218: note:          def spawn_later(cls, seconds: float) -> Greenlet[[], None]
+ ddtrace/profiling/_gevent.py:218: note:          def spawn_later(cls, seconds: float | int) -> Greenlet[[], None]
- ddtrace/profiling/_gevent.py:302: error: Incompatible types in assignment (expression has type "def joinall(greenlets: Sequence[Greenlet[Any, Any]], *args: Any, **kwargs: Any) -> Sequence[Greenlet[Any, Any]]", variable has type "Callable[[Sequence[_G], float | None, bool, int | None], list[_G]]")  [assignment]
+ ddtrace/profiling/_gevent.py:302: error: Incompatible types in assignment (expression has type "def joinall(greenlets: Sequence[Greenlet[Any, Any]], *args: Any, **kwargs: Any) -> Sequence[Greenlet[Any, Any]]", variable has type "Callable[[Sequence[_G], float | int | None, bool, int | None], list[_G]]")  [assignment]
- ddtrace/profiling/_gevent.py:326: error: Incompatible types in assignment (expression has type "Callable[..., Sequence[Greenlet[Any, Any]]]", variable has type "Callable[[Sequence[_G], float | None, bool, int | None], list[_G]]")  [assignment]
+ ddtrace/profiling/_gevent.py:326: error: Incompatible types in assignment (expression has type "Callable[..., Sequence[Greenlet[Any, Any]]]", variable has type "Callable[[Sequence[_G], float | int | None, bool, int | None], list[_G]]")  [assignment]

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant