-
-
Notifications
You must be signed in to change notification settings - Fork 2k
[tkinter] Annotate few methods #15273
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
base: main
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
| @overload | ||
| def wantobjects(self) -> int: ... | ||
| @overload | ||
| def wantobjects(self, wantobjects: int, /) -> None: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least for Python 3.12, these are bools:
Python 3.12.3 (main, Jan 8 2026, 11:30:50) [GCC 13.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter
>>> tkinter.Tk().wantobjects()
True
| @overload | |
| def wantobjects(self) -> int: ... | |
| @overload | |
| def wantobjects(self, wantobjects: int, /) -> None: ... | |
| @overload | |
| def wantobjects(self) -> bool: ... | |
| @overload | |
| def wantobjects(self, wantobjects: bool, /) -> None: ... |
| def adderrorinfo(self, msg: str, /) -> None: ... | ||
| def call(self, command: Any, /, *args: Any) -> Any: ... | ||
| def createcommand(self, name: str, func, /): ... | ||
| def createcommand(self, name: str, func: Callable[..., object], /) -> None: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure that func takes arbitrary arguments? Maybe @Akuli, our resident tkinter expert has some insights. We should at least leave a TODO comment to check this.
| if sys.platform != "win32": | ||
| def createfilehandler(self, file, mask: int, func, /): ... | ||
| def deletefilehandler(self, file, /) -> None: ... | ||
| def createfilehandler(self, file: FileDescriptorLike, mask: int, func: Callable[..., object], /) -> None: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question here.
|
|
||
| def createtimerhandler(self, milliseconds: int, func, /): ... | ||
| def dooneevent(self, flags: int = 0, /): ... | ||
| def createtimerhandler(self, milliseconds: int, func: Callable[..., object], /): ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here.
| def createcommand(self, name: str, func: Callable[..., object], /) -> None: ... | ||
| if sys.platform != "win32": | ||
| def createfilehandler(self, file, mask: int, func, /): ... | ||
| def deletefilehandler(self, file, /) -> None: ... | ||
| def createfilehandler(self, file: FileDescriptorLike, mask: int, func: Callable[..., object], /) -> None: ... | ||
| def deletefilehandler(self, file: FileDescriptorLike, /) -> None: ... | ||
|
|
||
| def createtimerhandler(self, milliseconds: int, func, /): ... | ||
| def deletecommand(self, name: str, /): ... | ||
| def dooneevent(self, flags: int = 0, /): ... | ||
| def createtimerhandler(self, milliseconds: int, func: Callable[..., object], /): ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above.
| def exprlong(self, s: str, /): ... | ||
| def exprstring(self, s: str, /): ... | ||
| def evalfile(self, fileName: str, /) -> str: ... | ||
| def exprboolean(self, s: str, /) -> int: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| def exprboolean(self, s: str, /) -> int: ... | |
| def exprboolean(self, s: str, /) -> Literal[0, 1]: ... |
| def exprlong(self, s: str, /): ... | ||
| def exprstring(self, s: str, /): ... | ||
| def evalfile(self, fileName: str, /) -> str: ... | ||
| def exprboolean(self, s: str, /) -> int: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| def exprboolean(self, s: str, /) -> int: ... | |
| def exprboolean(self, s: str, /) -> Literal[0, 1]: ... |
| @overload | ||
| def wantobjects(self) -> int: ... | ||
| @overload | ||
| def wantobjects(self, wantobjects: int, /) -> None: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| @overload | |
| def wantobjects(self) -> int: ... | |
| @overload | |
| def wantobjects(self, wantobjects: int, /) -> None: ... | |
| @overload | |
| def wantobjects(self) -> bool: ... | |
| @overload | |
| def wantobjects(self, wantobjects: bool, /) -> None: ... |
Based on: https://github.com/python/cpython/blob/main/Modules/_tkinter.c