-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Adds docs about types
module
#11285
Adds docs about types
module
#11285
Conversation
``typing`` is used for type annotations, | ||
while ``types`` is used to define useful runtime types and primitives. | ||
|
||
Types from ``types`` module are not recognised by a type checker, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't always true; a few types in types
are useful in annotations (e.g. TracebackType
, which is used in __exit__
annotations).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh no 😆
I was not aware of that. Any others?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think some people use types.FunctionType
? Also I think I've seen types.ModuleType
a few times.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Various types in types
are properly typed and recognized by type checkers, such as GeneratorType
, MappingProxyType
, EllipsisType
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ethanhs ok, then we need a new plan. Maybe we can focus on "valid" usecases of using types
? Experience from typeshed
will totally help! 👍
I also don't know that this is a particularly common issue. |
From my experience it is common, people be seeing a module called |
related: #11288 |
I'm not saying confusion isn't understandable, nor that we shouldn't have documentation addressing this. Just that few users have even heard of |
Citing @erictraut #11286 (comment)
|
Closes #11275