Skip to content

Commit

Permalink
Fix clone() and with_...() methods for AsyncClient (#457)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarshalX authored Nov 23, 2024
1 parent d030829 commit 2116fcb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 26 deletions.
13 changes: 0 additions & 13 deletions packages/atproto_client/client/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import typing as t
from asyncio import Lock

import typing_extensions as te
from atproto_core.uri import AtUri

from atproto_client import models
Expand Down Expand Up @@ -77,18 +76,6 @@ async def _import_session_string(self, session_string: str) -> Session:

return import_session

async def clone(self) -> te.Self:
"""Clone the client instance.
Used to customize atproto proxy and set of labeler services.
Returns:
Cloned client instance.
"""
cloned_client = super().clone()
cloned_client.me = self.me
return cloned_client

async def login(
self, login: t.Optional[str] = None, password: t.Optional[str] = None, session_string: t.Optional[str] = None
) -> 'models.AppBskyActorDefs.ProfileViewDetailed':
Expand Down
13 changes: 0 additions & 13 deletions packages/atproto_client/client/client.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import typing as t
from threading import Lock

import typing_extensions as te
from atproto_core.uri import AtUri

from atproto_client import models
Expand Down Expand Up @@ -68,18 +67,6 @@ def _import_session_string(self, session_string: str) -> Session:

return import_session

def clone(self) -> te.Self:
"""Clone the client instance.
Used to customize atproto proxy and set of labeler services.
Returns:
Cloned client instance.
"""
cloned_client = super().clone()
cloned_client.me = self.me
return cloned_client

def login(
self, login: t.Optional[str] = None, password: t.Optional[str] = None, session_string: t.Optional[str] = None
) -> 'models.AppBskyActorDefs.ProfileViewDetailed':
Expand Down
12 changes: 12 additions & 0 deletions packages/atproto_client/client/methods_mixin/headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ class AtprotoServiceType(Enum):
ATPROTO_LABELER = 'atproto_labeler'
BSKY_CHAT = 'bsky_chat'

def clone(self) -> te.Self:
"""Clone the client instance.
Used to customize atproto proxy and set of labeler services.
Returns:
Cloned client instance.
"""
cloned_client = super().clone()
cloned_client.me = self.me
return cloned_client

def with_proxy(self, service_type: t.Union[AtprotoServiceType, str], did: str) -> te.Self:
"""Get a new client instance with the atproto-proxy header configured.
Expand Down

0 comments on commit 2116fcb

Please sign in to comment.