-
-
Notifications
You must be signed in to change notification settings - Fork 3k
[mypyc] Using UnboundedType to access class object of a type annotation. #18874
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -78,17 +78,22 @@ assert hasattr(c, 'x') | |
|
|
||
| [case testTypedDictWithFields] | ||
| import collections | ||
| import json | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if import a as b
import b as a
...
# b.C in an annotation refers to fullname a.C!Similarly, what if we have It's okay to not support all possible cases yet -- we can create follow-up issues -- but it would be nice if we can avoid having references to incorrect types.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Both those cases are not supported. Opened mypyc/mypyc#1099 and referenced in a comment. |
||
| from typing import TypedDict | ||
| class C(TypedDict): | ||
| x: collections.deque | ||
| spam: json.JSONDecoder | ||
| [file driver.py] | ||
| from native import C | ||
| from collections import deque | ||
| from json import JSONDecoder | ||
|
|
||
| print(C.__annotations__["x"] is deque) | ||
| print(C.__annotations__["spam"] is JSONDecoder) | ||
| [typing fixtures/typing-full.pyi] | ||
| [out] | ||
| True | ||
| True | ||
|
|
||
| [case testClassWithDeletableAttributes] | ||
| from typing import Any, cast | ||
|
|
||
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.
Style nit: some of the comments seem to be longer than 99 characters, which is our line length limit. Can you wrap any long lines?
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.
Fixed.