Repository navigation
Conversation
Tk 9.0 lets ttk::progressbar show a text label and adds the anchor, font, foreground, justify, text and wraplength options. Progressbar has an explicit signature with no **kw, so passing any of them was a type error. Add them to __init__ and configure with the types ttk.Label uses. Closes python#16612
This comment has been minimized.
This comment has been minimized.
|
The three failing |
|
As far as I can tell, there's no good way to deal with features added in Tcl/Tk 9.0. It's still perfectly reasonable to support Tk 8.6, and there's also no good way to say "if Tcl/Tk 9.0 is available" in a stub. Ideally, the user of whatever tool uses the stub (type checker, language server, IDE, who knows) would provide some parameter to the stubs, but nothing quite like that exists. So, I think the least bad option we have is just commenting. Can you add a comment like |
|
Done. I added |
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Closes #16612.
Tk 9.0 lets
ttk::progressbardisplay a text label inside the bar and adds six options for it:anchor,font,foreground,justify,textandwraplength(Tk 9.0 man page). Compared with the Tk 8.6 page, no options were removed; these six are the only difference.Progressbar.__init__andconfigurehave explicit signatures with no**kw, so code using these options is rejected onmain:This PR adds the six options to both, using the same types
ttk.Labeluses for them.tkintercan be built against Tk 8.6 or 9.0, and typeshed can't tell which one it is, so the options aren't version-gated. A comment notes they need Tk 9.0. On Tk 8.6, passing them is a runtime error rather than a type error, which follows typeshed's usual preference for false negatives over false positives.Checks:
tests/mypy_test.py stdlib/tkinter -p 3.10 -p 3.14,pyright,ruff,blackandcheck_typeshed_structure.pyall pass, and the example above type-checks cleanly with the change.