Skip to content

Is there a way to type-alias a generic type? #697

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

Closed
desmond-dsouza opened this issue May 27, 2015 · 2 comments
Closed

Is there a way to type-alias a generic type? #697

desmond-dsouza opened this issue May 27, 2015 · 2 comments

Comments

@desmond-dsouza
Copy link

Can I write a generic type-aliase so that:

MyBundle[t] is exactly equivalent to Tuple[List[t], t, List[t]]

@spkersten
Copy link
Contributor

This will be possible in the future, but is not yet supported by mypy. See #606 and the ambv/typehinting issue it refers to.

@JukkaL
Copy link
Collaborator

JukkaL commented May 31, 2015

I chatted about this with Guido and he's only planning to support simple aliases like this:

X = Tuple[T, int]

# Now X[str] is equivalent to Tuple[str, int]

Cases where the type variable is deeply nested in the alias target probably won't be supported. If you care about this, you should probably ask about it on the ambv/typehinting issue. I actually promised to add this feature to PEP 484, but I haven't yet done it...

@JukkaL JukkaL closed this as completed May 31, 2015
msullivan added a commit that referenced this issue Sep 7, 2019
This operates by providing default implementations of `__getstate__`
and `__setstate__` for extension classes. Our implementations work by
storing a `__mypyc_attrs__` tuple in each class that we generate and
collecting all of the attributes in it into a dict.

Fixes #697.
msullivan added a commit that referenced this issue Sep 9, 2019
This operates by providing default implementations of `__getstate__`
and `__setstate__` for extension classes. Our implementations work by
storing a `__mypyc_attrs__` tuple in each class that we generate and
collecting all of the attributes in it into a dict.

Fixes #697.
msullivan added a commit that referenced this issue Sep 9, 2019
This operates by providing default implementations of `__getstate__`
and `__setstate__` for extension classes. Our implementations work by
storing a `__mypyc_attrs__` tuple in each class that we generate and
collecting all of the attributes in it into a dict.

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

No branches or pull requests

3 participants