Don't use Literal for tkinter widget options #4891
Merged
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.
Fixes #4889
Using
Literal
incget
was the most controversial part of #4363. By instead makingcget
and__getitem__
behave in exactly the same way, we can putcget
toMisc
, the base class that all widgets inherit from. This is also how it's actually done intkinter/__init__.py
. Now any object with typeMisc
has a.cget()
method as expected.I also tried to do the same thing with the
configure()
method, but that's not perfect:configure()
, and I could only get one of them to work inMisc
. The other one takes widget-specific keyword arguments, and I don't know what should correspond with that in theMisc
base class. I tried**kw: Any
, but that wasn't compatible with the widget-specificconfigure()
methods with specific options.config
is an alias forconfigure
, and trying to add it toMisc
(withdef
or withconfig = configure
) creates mypy errors for some reason.