-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Remove type checker-specific symbols from builtins.pyi and typing.pyi #7580
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
Comments
contains some insight into why But changes that we made to |
#13816 is a first step towards solving it, by making the symbols available in the module I've left out |
For reference, I've linked this issue and the PR on discuss.python.org: https://discuss.python.org/t/removing-type-checker-internals-from-typeshed/87960 |
See the initial comment of #13816 for the current proposal. I'll try to keep it updated according to the consensus of the discussion. |
Thanks for doing this work. Transitioning to the new types will be a little tricky to coordinate between typeshed and all the type checkers. Would it make sense to provide aliases in |
The idea is to keep the existing definitions for the time being, and only remove them when we're reasonably sure that type checkers have adopted the new names. |
Instead of adding Looking at the current PR:
(Also I removed my assignment; I intended to work on this a few years ago but never had the time, sorry!) |
According to @erictraut in python/mypy#8240 (comment), pyright uses it (but that was three years ago!) |
From red-knot's perspective, I'd prefer for these fallback stubs to continue to be hosted at typeshed, I think. #13646 is a great example of a bug in these stubs that was caught by typeshed's CI, but which might have taken much longer to spot if red-knot had to maintain its own version of a stub for |
Ideally yes. But this is probably a fairly easy change for type checkers for now, and – in my opinion – a considerable improvement for us. Stopping to rely on typeshed might need bigger changes. |
+1 to copying these symbols out of builtins and typing (and eventually removing them from there). Echoing @AlexWaygood , I'd prefer for TypedDictFallback and NamedTupleFallback to remain in _typeshed, as they're potentially useful for all type checkers. (Pyrefly is already using typing.NamedTuple.) |
I'm working to get rid of the type checker-specific symbols that currently are in our core stubs but don't exist at runtime. I'll use this issue to track the work needed. This involves changes both to typeshed and to type checkers.
Affected names:
typing._TypedDict
. Suggesting to rename to_typeshed.TypedDictFallback
. (mypy and pyright)typing._promote
->_typeshed._promote
(mypy only)typing.AwaitableGenerator
->_typeshed.AwaitableGenerator
(mypy and pyright)builtins.function
(mypy and pyright). Need to look more into why we can't just usetypes.FunctionType
.builtins.ellipsis
(mypy and pyright). Should add a new name to _typeshed, similar toNoneType
.builtins.module
was also mentioned in the past but it's been fixed already (mypy PR: python/mypy#3107).Linked issues and PRs:
function
from builtins #2999ellipsis
type mypy#11564The text was updated successfully, but these errors were encountered: