| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Sorry, something went wrong.
|
This is less readable. What problem does this solve? |
Sorry, something went wrong.
See conversation in #11505 (comment). I had the same initial reaction, but pyright's error is, strictly speaking, correct here. It's invalid to have a pos-only parameter following a pos-or-keyword parameter, and stubtest correctly complains about the alternative solution I thought of. |
Sorry, something went wrong.
|
I still don't see a practical problem being solved. Type checkers will generally tolerate small issues in stubs as long as they can understand what the stubs are trying to say. On the other hand, IDE users will not be happy trying to decipher the new Unpack contraption. |
Sorry, something went wrong.
|
I'd be okay reverting if we add test cases to make sure type checkers understand that it's valid at runtime to pass default using a keyword argument. But note that there's no way of directly translating what we had before this PR into PEP-570 syntax -- with PEP-570, all parameters before the / are positional-only. And we're hoping to soon move to PEP-570 everywhere (#11250). |
Sorry, something went wrong.
It's not. This method cannot be called so that you pass a keyword argument for default. If you try to do it, python will complain that you're passing two values for it: >>> import tkinter
>>> root = tkinter.Tk()
>>> root.wm_iconphoto('lol', default=True)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: Wm.wm_iconphoto() got multiple values for argument 'default'
I now see that the old way to write the stub with default and __image1 is wrong/misleading, but I still don't like what this PR did. |
Sorry, something went wrong.
Got it -- my mistake. FWIW, I did test locally, but obviously not thoroughly enough :) In that case, we should be able to simply update the signature to the much-simpler def wm_iconphoto(self, default: bool, image1: _PhotoImageLike | str, /, *args: _PhotoImageLike | str) -> None: ... |
Sorry, something went wrong.
To be honest, the whole wm_iconphoto() method is a mess. A positional-only boolean parameter is just a bad idea for readability, but it's too late to change it now: that would break every tkinter program that sets a custom icon for the app. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Same as #11505