Skip to content
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

Implement TypeVar bounds with an intersection bound #2702

Closed
graingert opened this issue Jan 17, 2017 · 4 comments
Closed

Implement TypeVar bounds with an intersection bound #2702

graingert opened this issue Jan 17, 2017 · 4 comments

Comments

@graingert
Copy link
Contributor

For type variables that extend multiple interfaces

<T extends I1 & I2>

@gvanrossum
Copy link
Member

Can you describe your use case for this feature, with some examples?

It sounds related to the Intersection proposed in the typing repo.

In general a new feature like this should probably be discussed in the typing repo first, since it would require changes to the typing.py module (which is gated by stdlib releases).

@ilevkivskyi
Copy link
Member

@gvanrossum Assuming the original syntax is taken from Java, this is what I proposed in the issue you mentioned, T = TypeVar('T', bound=Intersection[t1, t2]). As I mentioned in that issue, the most obvious use case is when types t1, t2 are ABCs (similar to interfaces in Java).

@graingert
Copy link
Contributor Author

ah yes, this is just python/typing#213 I was searching under TypeVar

@gvanrossum
Copy link
Member

OK, closing in favor of #213.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants