-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Support for functions producing generic functions #3113
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 1 commit
679a172
74e9262
5470c77
12def8b
52782fe
0184595
757a6b8
57bca93
3b8bc23
82da335
9f12644
8cf4fa6
2634277
30dba10
7b4f9f2
daf9592
826b9cf
4141f94
58e3a2a
c061a09
603013d
c6fec63
f46d52a
ea21337
80d62a7
eaf8c0d
5009a2b
7c64464
a866d0f
9d5c630
4683d70
cbb3cb0
da0d936
edbecb0
21d8b13
214aebc
5405646
a25e926
4aaab6c
fd153ad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -940,14 +940,6 @@ from typing import Generic | |
class A(Generic[int]): pass # E: Free type variable expected in Generic[...] | ||
[out] | ||
|
||
[case testInvalidTypeWithinNestedGenericClass] | ||
from typing import Generic, TypeVar | ||
T = TypeVar('T') | ||
class A(Generic[T]): | ||
class B(Generic[T]): pass \ | ||
# E: Free type variable expected in Generic[...] | ||
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. This appears in PEP 484 as an example of an error. I think it should still be prohibited. 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. Oh, yes, you're totally right. According to PEP484 you can neither make the inner class generic in the same tvar, nor use the outer tvar in the inner class. I'll adjust as necessary. |
||
[out] | ||
|
||
[case testIncludingGenericTwiceInBaseClassList] | ||
from typing import Generic, TypeVar | ||
T = TypeVar('T') | ||
|
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.
The above line is the punchline of this diff. Make a layer of type variable scope when analyzing a callable type, so it can bind its own type variables if it needs to.
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.
Add a code comment with contents similar to the second sentence in the above comment?