forked from vercel/python-typemap
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
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
AttrsandGetMemberType
References
- TypeScript Pick: https://www.typescriptlang.org/docs/handbook/utility-types.html#picktype-keys
- TypeScript Omit: https://www.typescriptlang.org/docs/handbook/utility-types.html#omittype-keys
Acceptance criteria
- Pick works with classes
- Omit works with classes
- Pick works with TypedDict
- Omit works with TypedDict
- Runtime evaluator implemented
- Unit tests added
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels