python / typeshed

Collection of library stubs for Python, with static types
Other
4.37k stars 1.75k forks source link

tkinter: stdlib but not really #5589

Open Akuli opened 3 years ago

Akuli commented 3 years ago

While tkinter is technically stdlib, it feels like a third-party package in a couple ways:

We could consider moving tkinter stubs from stdlib/ to stubs/. This would create a types-tkinter project on pypi that is auto-updated when pull requests are merged, even though you aren't supposed to pip install tkinter.

JukkaL commented 3 years ago

This sounds reasonable to me. Tkinter somehow feels like a separate entity from the rest of the stdlib in my mind, even though it's included with CPython. It also has larger stubs than most stdlib packages, so it's perhaps likely that users would like to update tham. Though I rarely use tkinter, so take my opinion with a grain of salt.

JelleZijlstra commented 3 years ago

My main worry is that this will be confusing to users who might not understand that tkinter is treated specially by typing. If we make this change, how should we communicate it to users?

JukkaL commented 3 years ago

Mypy would likely generate an error and suggest installing types-tkinter if the stubs are missing, but the code being type checked imports it. We'd also mention this in the mypy release notes. I think that this would be self-explanatory. Tools that ship the entire typeshed shouldn't be affected at all.

srittau commented 3 years ago

I am not a big fan of this, after all tkinter is part of the stdlib. A similar rationale could be used for quite a few other stdlib modules, e.g. asyncio, statistics, curses, turtle, ssl. Why should they be part of the stdlib if ssl is not? But this begs another question: Could the stdlib be distributed separately from type checkers, with type checkers declaring a dependency?

Hawk777 commented 3 years ago

I don’t have a strong opinion. I don’t write a lot of Python these days, much less with tkinter—I use it occasionally when a project calls for it, not on a day-to-day basis.

Akuli commented 3 years ago

Here's another idea: why not auto-upload types-foo packages of all stdlib modules? That way a project doesn't have to bundle typeshed in a git submodule just to use some fix in typeshed. Type checkers wouldn't have to suggest installing those automatically, because the stdlib bundled with the type checker is usually good enough.