- 
                Notifications
    
You must be signed in to change notification settings  - Fork 5
 
Open
Description
Bringing this up because I'm writing something like this in a separate project:
When writing functions that work equally well for V2 Arrays or V3 arrays (and the same for groups), it would be useful to have a array-like type that doesn't depend on the V2 / V3 Array classes, but works for both. These could be very simple runtime checkable protocols:
from typing import Protocol, runtime_checkable, Generic
@runtime_checkable
class ProtoNode(Protocol):
    attributes: Mapping[str, Any]
@runtime_checkable
class ProtoArray(Protocol):
    shape: tuple[int, ...]
TMembers = TypeVar('TMembers', bound=Mapping[str, object])
@runtime_checkable
class ProtoGroup(Protocol, Generic[TMembers]):
    members: TMembersThis is just a sketch -- these can be made fancier of course, and the names are bad, etc.
Metadata
Metadata
Assignees
Labels
No labels