-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Support usage of type
with typing.Self
and type aliases
#10621
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
Conversation
type[Self]
type[Self]
; add typecheck for type[]
type[Self]
; add typecheck for type[]
type[Self]
; check the content of type[]
is a class
CodSpeed Performance ReportMerging #10621 will not alter performanceComparing Summary
|
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
type[Self]
; check the content of type[]
is a classtype[Self]
and type[TypeAliasType(...)]
type[Self]
and type[TypeAliasType(...)]
type[Self]
and type[TypeAliasType(...)]
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.
Thanks for looking at this!
type[Self]
and type[TypeAliasType(...)]
type
with typing.Self
and type aliases
Co-authored-by: Victorien <65306057+Viicos@users.noreply.github.com>
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.
Looking good, nice work on the tests.
Wanted to resolve some questions about the _typing_extra.eval_type
call - perhaps we could jump right to a type alias schema if one is detected...
I tried this snippet in Python 3.8, 3.10 and 3.12. Something interesting happed. tp=List['int']
tp_eval=typing._eval_type(tp, globals(), locals())
print(typing.get_args(tp))
print(typing.get_args(tp_eval))
tp=list['int']
tp_eval=typing._eval_type(tp, globals(), locals())
print(typing.get_args(tp))
print(typing.get_args(tp_eval)) The results are:
So this means (only?) when user annotate with |
This was done in python/cpython#30900. |
Co-authored-by: Victorien <65306057+Viicos@users.noreply.github.com>
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.
Thanks!
Change Summary
Fix errors caused by these:
Related issue number
fix #10618
Checklist