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

ENH: Allow the use of type-aliases in the typing tests #17617

Closed
BvB93 opened this issue Oct 23, 2020 · 1 comment · Fixed by #18066
Closed

ENH: Allow the use of type-aliases in the typing tests #17617

BvB93 opened this issue Oct 23, 2020 · 1 comment · Fixed by #18066

Comments

@BvB93
Copy link
Member

BvB93 commented Oct 23, 2020

Mypys' string representation of certain types can get quite verbose, especially when larger Unions are involved.
Ideally we should be able to use aliases when running the reveal tests, allowing us to keep things a bit more compact:

reveal_type(c16 + c16) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
reveal_type(c16 + f8) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
reveal_type(c16 + i8) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]

For further reference: there is currently a mypy issue with a similar request, but who know when/if
this will be implemented (python/mypy#9381).

@BvB93
Copy link
Member Author

BvB93 commented Nov 30, 2020

Another use case as encountered in #17843 and #17514: platform-specific types. Describing a dynamically assigned class with a static comment has proved somewhat troublesome:

import numpy as np

p: np.intp

# Can be either `numpy.signedinteger[numpy.typing._64Bit]` or `numpy.signedinteger[numpy.typing._32Bit]`
reveal_type(p)  # E: numpy.signedinteger[numpy.typing._

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

Successfully merging a pull request may close this issue.

1 participant