-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Idea: "Incomplete" marker #5613
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
Of course, stubgen should be taught this type if we would do something like this. |
I like the idea of being more explicit what is meant by Any. Pyright uses a similar concept internally (https://github.com/microsoft/pyright/blob/7bb059ecbab5c0c446d4dcf5376fc5ce8bd8cd26/docs/type-inference.md#type-inference), so maybe we can help Pyright by similarly separating Any and Unknown in typeshed. |
Selfishly from the pyright POV, A half idea, but I wonder if @erictraut for his thoughts. |
Maybe we can come up with a better name. Unknown also means something different in Typescript. |
|
Why not simply omit type annotations when they are not yet known? That's what most stubs do today, and it works well. I don't see a need to make this explicit. Tools like pyright can indicate when these types are omitted. The only downside is that you wouldn't be able to specify unions that include partially-known types, like in the example above, but I see this as an edge case, and I think it's fine to omit the entire annotation in this case. |
The edge case is quite common and it's unfortunate to lose the partial type information in this case. It's both worse for users that get less type security, and worse for type stub authors that have more work when updating the stubs. Especially since this information is easily auto generated by stubgen. |
OK, that argument makes sense to me. How would you propose defining |
Yes, as this is basically a replacement for |
Although thinking about it, it would make some sense to include this type into "incomplete type" warnings in type checkers. |
|
When creating stubs, we encourage contributors to leave items unannotated instead of using
Any
. This often works, but there are cases where you have to fall back onAny
, for example:In this case the best we can do is:
In this case it's not clear if
Any
is used, because there is no better alternative or because this needs better annotations.Idea: We could introduce an alias for
Any
in_typeshed
, called something likeIncomplete
,Unknown
(my current favorite),Something
,Untyped
, orUnannotated
. This could clearly mark that this argument type still needs work:This has a few advantages:
Any
to find areas where the type system could be improved or where newer type system features could be used.The text was updated successfully, but these errors were encountered: