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

Allow PEP 646 variadic generics syntax? #103

Open
burnpanck opened this issue Mar 14, 2023 · 1 comment
Open

Allow PEP 646 variadic generics syntax? #103

burnpanck opened this issue Mar 14, 2023 · 1 comment
Labels
feature A new feature

Comments

@burnpanck
Copy link

PEP 646 Variadic Generics have landed in python 3.11, which allow generics to be written that accept a variable number of arguments, and the prime use-case is for numpy-like arrays. As far as I can tell however, neither numpy itself, nor the python standard library ship actual typings making use of that. Given that nptyping already supports that use-case just through the use of strings instead of variadic generics, it may be reasonable to extend to the new syntax. Is that something which aligns with the library's vision?

@ramonhagenaars
Copy link
Owner

Hi Burnpanck,

Variadic generics are indeed on this library's radar. I would use it to support more generic types, for example indices in DataFrames. This is how it could look like:

from nptyping import Structure as S, Index  # note: Index does not exist yet

DataFrame[S["a: Int, b: Float"]]  # hint a structured DataFrame
DataFrame[Index["a"]]  # only hint an index
DataFrame[S["a: Int, b: Float"], Index["a"]]  # hint a structure and an index

However, mypy support is still in progress (see python/mypy#12280) and nptyping wants to stay mypy-compliant. Once mypy has implemented support, nptyping will follow.

@ramonhagenaars ramonhagenaars added the feature A new feature label Mar 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A new feature
Projects
None yet
Development

No branches or pull requests

2 participants