Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix clone() and with_...() methods for AsyncClient #457

Merged
merged 1 commit into from
Nov 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading