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

Add support for Dict, List, set, frozenset, Tuple[T, ...], tuple[T, ...] #221

Merged
merged 2 commits into from
Nov 9, 2022

Conversation

dairiki
Copy link
Collaborator

@dairiki dairiki commented Nov 9, 2022

We already support a parameterless dict (which we treat equivalently to Dict[Any, Any]). This PR adds support for a parameterless Dict as well. (See #181).

Similarly, this adds support for List.

We also add support for the builtin set and frozenset. (We already supported Set and FrozenSet.)


In addition, this PR adds support for homogeneous tuples notated as Tuple[T, ...] (or tuple[T, ...] for python 3.9 and above.)
We currently support homogeneous tuples only through the notation Sequence[T]. (It seems generally more correct to me to use concrete rather than abstract types in dataclass declarations — though perhaps arguments could be made either way.)

We already supported `dict` (without explicit generic type
parameters), but did not support `Dict`.  (Similarly for `list` and
`List`.)

We supported `typing.Set`, but not the builtin `set`.  (Similarly for
`typing.FrozenSet` and `frozenset`.)

We now support all of the above.

Fixes lovasoa#181.
We currently recognize `typing.Sequence[int]` as a homogeneous tuple
of ints.  This adds support for the (probably more correct) concrete
type `tuple[int, ...]` (or `typing.Tuple[int, ...]`).
@dairiki dairiki merged commit 65ed180 into lovasoa:master Nov 9, 2022
@dairiki dairiki deleted the bug.181-parameterless_generics branch November 9, 2022 20:55
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

Successfully merging this pull request may close these issues.

1 participant