Skip to content

Replace all FloatInt arguments that have an int default - #16964

Merged
srittau merged 3 commits into
python:mainfrom
srittau:float-int-int-default
Dec 3, 2026
Merged

srittau merged 3 commits into
python:mainfrom
srittau:float-int-int-default

Conversation

@srittau

@srittau srittau commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

With float | int, because these obviously also accept int.

@srittau
srittau requested review from Akuli and Avasam as code owners December 2, 2026 21:57
@github-actions

This comment has been minimized.

@srittau srittau changed the title Replace all FloatInt arguments with an int default Replace all FloatInt arguments that have an int default Dec 2, 2026
@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@Akuli Akuli left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a reasonable approach to me, and I don't think it's going to make anything less correct than before. I reviewed the tkinter changes in more detail.

variable: Variable | Literal[""] = ...,
width: FloatInt | str = 0,
wraplength: FloatInt | str = 0,
width: float | int | str = 0,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

width and height are wrong for tkinter.Checkbutton and tkinter.Radiobutton. This means that the stubs were wrong before, not that the approach of this PR would be somehow wrong.

>>> import tkinter
>>> tkinter.Checkbutton(width=5.6)
Traceback (most recent call last):
  File "<python-input-2>", line 1, in <module>
    tkinter.Checkbutton(width=5.6)
    ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
  File "/usr/lib/python3.13/tkinter/__init__.py", line 3203, in __init__
    Widget.__init__(self, master, 'checkbutton', cnf, kw)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/tkinter/__init__.py", line 2777, in __init__
    self.tk.call(
    ~~~~~~~~~~~~^
        (widgetName, self._w) + extra + self._options(cnf))
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_tkinter.TclError: expected integer but got "5.6"

I think it's cleanest to fix this afterwards in another PR, so that this one remains purely auto-generated.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Akuli Do you want to write the PR and I review?

@srittau
srittau merged commit 179ab5e into python:main Dec 3, 2026
91 checks passed
@srittau
srittau deleted the float-int-int-default branch December 3, 2026 17:37
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.

2 participants