Skip to content

Implement Pick[T, K] and Omit[T, K] type utilities #2

@AliiiBenn

Description

@AliiiBenn

Description

Add Pick and Omit type utilities similar to TypeScript's Pick and Omit.

Specification

Pick[T, K] - Select only the specified properties K from type T
Omit[T, K] - Exclude the specified properties K from type T

class User:
    name: str
    email: str
    age: int

Pick[User, 'name' | 'email'] = { name: str; email: str }
Omit[User, 'age'] = { name: str; email: str }

Implementation notes

  • K should be a union of literal keys
  • Should work with classes and TypedDict
  • Can leverage existing Attrs and GetMemberType

References

Acceptance criteria

  • Pick works with classes
  • Omit works with classes
  • Pick works with TypedDict
  • Omit works with TypedDict
  • Runtime evaluator implemented
  • Unit tests added

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions