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

GroupSpec signature #20

Open
d-v-b opened this issue Nov 9, 2023 · 0 comments
Open

GroupSpec signature #20

d-v-b opened this issue Nov 9, 2023 · 0 comments

Comments

@d-v-b
Copy link
Collaborator

d-v-b commented Nov 9, 2023

Currently we have

TAttr = TypeVar("TAttr", bound=Mapping[str, Any])
TItem = TypeVar("TItem", bound=Union["GroupSpec", "ArraySpec"])

class GroupSpec(NodeSpecV2, Generic[TAttr, TItem]):
    attributes: TAttr
    members: dict[str, TItem]

This excludes the key space of members from the type domain (the keys can be any strings).

What if we did this instead:

TAttr = TypeVar("TAttr", bound=Mapping[str, Any])
TItem = TypeVar("TItem", bound=Dict[str, Union["GroupSpec", "ArraySpec"]])

class GroupSpec(NodeSpecV2, Generic[TAttr, TItem]):
    attributes: TAttr
    members: TItem

I think this would enable requiring that Zarr groups contain nodes with specific names, e.g.

class MyMembers(TypedDict):
    s0: ArraySpec[ArrayAttrs]
    s1: ArraySpec[ArrayAttrs]

GroupSpec[MyAttributes, MyMembers](...)

But it's not clear to how to make this play nice with pydantic models, since they can't be coerced to Dict[str, blablabla]

@d-v-b d-v-b changed the title GroupSpec signatue GroupSpec signature Dec 12, 2024
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

1 participant