Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
tribble committed Jul 22, 2024
1 parent 6da108d commit 2ee8b5d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 57 deletions.
2 changes: 0 additions & 2 deletions workos/resources/directory_sync.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from typing import List, Optional, Literal
from enum import Enum
from workos.resources.workos_model import WorkOSModel
from workos.typing.enums import EnumOrUntyped
from workos.typing.literals import LiteralOrUntyped

DirectoryState = Literal[
Expand Down
22 changes: 14 additions & 8 deletions workos/resources/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,24 @@ def auto_paging_iter(self):
data = []


# add all possible generics of List Resource
T = TypeVar("T", Organization, Directory, DirectoryGroup, DirectoryUser)
ListableResource = TypeVar(
# add all possible generics of List Resource
"ListableResource",
Organization,
Directory,
DirectoryGroup,
DirectoryUser,
)


class ListMetadata(BaseModel):
after: Optional[str] = None
before: Optional[str] = None


class ListPage(BaseModel, Generic[T]):
class ListPage(BaseModel, Generic[ListableResource]):
object: Literal["list"]
data: List[T]
data: List[ListableResource]
list_metadata: ListMetadata


Expand All @@ -134,17 +140,17 @@ class Config:
extra = "allow"


class WorkOsListResource(BaseModel, Generic[T]):
class WorkOsListResource(BaseModel, Generic[ListableResource]):
object: Literal["list"]
data: List[T]
data: List[ListableResource]
list_metadata: ListMetadata

# These fields end up exposed in the types. Does we care?
list_method: Callable = Field(exclude=True)
list_args: ListArgs = Field(exclude=True)

def auto_paging_iter(self) -> Iterator[T]:
next_page: WorkOsListResource[T]
def auto_paging_iter(self) -> Iterator[ListableResource]:
next_page: WorkOsListResource[ListableResource]

after = self.list_metadata.after
order = self.list_args.order
Expand Down
2 changes: 1 addition & 1 deletion workos/resources/organizations.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class OrganizationDomain(WorkOSModel):
id: str
organization_id: str
object: Literal["organization"]
object: Literal["organization_domain"]
verification_strategy: Literal["manual", "dns"]
state: Literal["failed", "pending", "legacy_verified", "verified"]
domain: str
Expand Down
46 changes: 0 additions & 46 deletions workos/typing/enums.py

This file was deleted.

0 comments on commit 2ee8b5d

Please sign in to comment.