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

Enable pydocstyle rules #226

Merged
merged 2 commits into from
Jan 10, 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
4 changes: 1 addition & 3 deletions examples/advanced_usage/auto_hyperlinks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
def extract_url_byte_positions(
text: str, *, aggressive: bool, encoding: str = 'UTF-8'
) -> t.List[t.Tuple[str, int, int]]:
"""
If aggressive is False, only links beginning http or https will be detected
"""
"""If aggressive is False, only links beginning http or https will be detected"""
encoded_text = text.encode(encoding)

if aggressive:
Expand Down
2 changes: 2 additions & 0 deletions fetch_new_lexicon.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Fetch lexicons from the latest commit and writes them to the lexicons folder."""
import typing as t
import zipfile
from io import BytesIO
Expand Down Expand Up @@ -108,6 +109,7 @@ def _remove_all_files_from_lexicons_folder() -> None:


def main() -> None:
"""Fetch lexicons from the latest commit and writes them to the lexicons folder."""
sha, commit_date, _ = _get_last_commit_info()

# FIXME(MarshalX): the script doesn't care about deleted lexicons
Expand Down
4 changes: 2 additions & 2 deletions packages/atproto_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


class AliasedGroup(click.Group):
"""Ref: https://click.palletsprojects.com/en/8.1.x/advanced/"""
"""Ref: https://click.palletsprojects.com/en/8.1.x/advanced/."""

def get_command(self, ctx: click.Context, cmd_name: str) -> t.Optional[click.Command]:
rv = click.Group.get_command(self, ctx, cmd_name)
Expand Down Expand Up @@ -40,7 +40,7 @@ def resolve_command(
@click.group(cls=AliasedGroup)
@click.pass_context
def atproto_cli(ctx: click.Context) -> None:
"""CLI of AT Protocol SDK for Python"""
"""CLI of AT Protocol SDK for Python."""
ctx.ensure_object(dict)


Expand Down
26 changes: 2 additions & 24 deletions packages/atproto_client/client/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ async def delete_post(self, post_uri: str) -> bool:
Raises:
:class:`atproto.exceptions.AtProtocolError`: Base exception.
"""

uri = AtUri.from_str(post_uri)
return await self.com.atproto.repo.delete_record(
models.ComAtprotoRepoDeleteRecord.Data(
Expand Down Expand Up @@ -203,7 +202,6 @@ async def send_image(
Raises:
:class:`atproto.exceptions.AtProtocolError`: Base exception.
"""

upload = await self.com.atproto.repo.upload_blob(image)
images = [models.AppBskyEmbedImages.Image(alt=image_alt, image=upload.blob)]
return await self.send_post(
Expand Down Expand Up @@ -231,7 +229,6 @@ async def get_post(
Raises:
:class:`atproto.exceptions.AtProtocolError`: Base exception.
"""

repo = self.me.did
if profile_identify:
repo = profile_identify
Expand Down Expand Up @@ -262,7 +259,6 @@ async def get_posts(self, uris: t.List[str]) -> models.AppBskyFeedGetPosts.Respo
Raises:
:class:`atproto.exceptions.AtProtocolError`: Base exception.
"""

return await self.app.bsky.feed.get_posts(
models.AppBskyFeedGetPosts.Params(
uris=uris,
Expand All @@ -276,14 +272,15 @@ async def get_post_thread(

Args:
uri: AT URI.
depth: Depth of the thread.
parent_height: Height of the parent post.

Returns:
:obj:`models.AppBskyFeedGetPostThread.Response`: Post thread.

Raises:
:class:`atproto.exceptions.AtProtocolError`: Base exception.
"""

return await self.app.bsky.feed.get_post_thread(
models.AppBskyFeedGetPostThread.Params(
uri=uri,
Expand All @@ -309,7 +306,6 @@ async def get_likes(
Raises:
:class:`atproto.exceptions.AtProtocolError`: Base exception.
"""

return await self.app.bsky.feed.get_likes(
models.AppBskyFeedGetLikes.Params(uri=uri, cid=cid, cursor=cursor, limit=limit)
)
Expand All @@ -331,7 +327,6 @@ async def get_reposted_by(
Raises:
:class:`atproto.exceptions.AtProtocolError`: Base exception.
"""

return await self.app.bsky.feed.get_reposted_by(
models.AppBskyFeedGetRepostedBy.Params(uri=uri, cid=cid, cursor=cursor, limit=limit)
)
Expand All @@ -352,7 +347,6 @@ async def get_timeline(
Raises:
:class:`atproto.exceptions.AtProtocolError`: Base exception.
"""

return await self.app.bsky.feed.get_timeline(
models.AppBskyFeedGetTimeline.Params(algorithm=algorithm, cursor=cursor, limit=limit)
)
Expand All @@ -374,7 +368,6 @@ async def get_author_feed(
Raises:
:class:`atproto.exceptions.AtProtocolError`: Base exception.
"""

return await self.app.bsky.feed.get_author_feed(
models.AppBskyFeedGetAuthorFeed.Params(actor=actor, cursor=cursor, fitler=filter, limit=limit)
)
Expand All @@ -391,7 +384,6 @@ async def like(self, subject: models.ComAtprotoRepoStrongRef.Main) -> models.Com
Raises:
:class:`atproto.exceptions.AtProtocolError`: Base exception.
"""

return await self.com.atproto.repo.create_record(
models.ComAtprotoRepoCreateRecord.Data(
repo=self.me.did,
Expand All @@ -412,7 +404,6 @@ async def unlike(self, like_uri: str) -> bool:
Raises:
:class:`atproto.exceptions.AtProtocolError`: Base exception.
"""

uri = AtUri.from_str(like_uri)
return await self.com.atproto.repo.delete_record(
models.ComAtprotoRepoDeleteRecord.Data(
Expand All @@ -437,7 +428,6 @@ async def repost(
Raises:
:class:`atproto.exceptions.AtProtocolError`: Base exception.
"""

return await self.com.atproto.repo.create_record(
models.ComAtprotoRepoCreateRecord.Data(
repo=self.me.did,
Expand All @@ -461,7 +451,6 @@ async def unrepost(self, repost_uri: str) -> bool:
Raises:
:class:`atproto.exceptions.AtProtocolError`: Base exception.
"""

uri = AtUri.from_str(repost_uri)
return await self.com.atproto.repo.delete_record(
models.ComAtprotoRepoDeleteRecord.Data(
Expand All @@ -483,7 +472,6 @@ async def follow(self, subject: str) -> models.ComAtprotoRepoCreateRecord.Respon
Raises:
:class:`atproto.exceptions.AtProtocolError`: Base exception.
"""

return await self.com.atproto.repo.create_record(
models.ComAtprotoRepoCreateRecord.Data(
repo=self.me.did,
Expand All @@ -504,7 +492,6 @@ async def unfollow(self, follow_uri: str) -> bool:
Raises:
:class:`atproto.exceptions.AtProtocolError`: Base exception.
"""

uri = AtUri.from_str(follow_uri)
return await self.com.atproto.repo.delete_record(
models.ComAtprotoRepoDeleteRecord.Data(
Expand All @@ -530,7 +517,6 @@ async def get_follows(
Raises:
:class:`atproto.exceptions.AtProtocolError`: Base exception.
"""

return await self.app.bsky.graph.get_follows(
models.AppBskyGraphGetFollows.Params(actor=actor, cursor=cursor, limit=limit)
)
Expand All @@ -551,7 +537,6 @@ async def get_followers(
Raises:
:class:`atproto.exceptions.AtProtocolError`: Base exception.
"""

return await self.app.bsky.graph.get_followers(
models.AppBskyGraphGetFollowers.Params(actor=actor, cursor=cursor, limit=limit)
)
Expand All @@ -568,7 +553,6 @@ async def get_profile(self, actor: str) -> models.AppBskyActorDefs.ProfileViewDe
Raises:
:class:`atproto.exceptions.AtProtocolError`: Base exception.
"""

return await self.app.bsky.actor.get_profile(models.AppBskyActorGetProfile.Params(actor=actor))

async def get_profiles(self, actors: t.List[str]) -> models.AppBskyActorGetProfiles.Response:
Expand All @@ -583,7 +567,6 @@ async def get_profiles(self, actors: t.List[str]) -> models.AppBskyActorGetProfi
Raises:
:class:`atproto.exceptions.AtProtocolError`: Base exception.
"""

return await self.app.bsky.actor.get_profiles(models.AppBskyActorGetProfiles.Params(actors=actors))

async def mute(self, actor: str) -> bool:
Expand All @@ -598,7 +581,6 @@ async def mute(self, actor: str) -> bool:
Raises:
:class:`atproto.exceptions.AtProtocolError`: Base exception.
"""

return await self.app.bsky.graph.mute_actor(models.AppBskyGraphMuteActor.Data(actor=actor))

async def unmute(self, actor: str) -> bool:
Expand All @@ -613,7 +595,6 @@ async def unmute(self, actor: str) -> bool:
Raises:
:class:`atproto.exceptions.AtProtocolError`: Base exception.
"""

return await self.app.bsky.graph.unmute_actor(models.AppBskyGraphUnmuteActor.Data(actor=actor))

async def resolve_handle(self, handle: str) -> models.ComAtprotoIdentityResolveHandle.Response:
Expand All @@ -628,7 +609,6 @@ async def resolve_handle(self, handle: str) -> models.ComAtprotoIdentityResolveH
Raises:
:class:`atproto.exceptions.AtProtocolError`: Base exception.
"""

return await self.com.atproto.identity.resolve_handle(
models.ComAtprotoIdentityResolveHandle.Params(handle=handle)
)
Expand All @@ -645,7 +625,6 @@ async def update_handle(self, handle: str) -> bool:
Raises:
:class:`atproto.exceptions.AtProtocolError`: Base exception.
"""

return await self.com.atproto.identity.update_handle(models.ComAtprotoIdentityUpdateHandle.Data(handle=handle))

async def upload_blob(self, data: bytes) -> models.ComAtprotoRepoUploadBlob.Response:
Expand All @@ -660,7 +639,6 @@ async def upload_blob(self, data: bytes) -> models.ComAtprotoRepoUploadBlob.Resp
Raises:
:class:`atproto.exceptions.AtProtocolError`: Base exception.
"""

return await self.com.atproto.repo.upload_blob(data)

#: Alias for :attr:`unfollow`
Expand Down
2 changes: 1 addition & 1 deletion packages/atproto_client/client/async_raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


class AsyncClientRaw(AsyncClientBase):
"""Group all root namespaces"""
"""Group all root namespaces."""

com: 'async_ns.ComNamespace'
app: 'async_ns.AppNamespace'
Expand Down
6 changes: 3 additions & 3 deletions packages/atproto_client/client/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class InvokeType(Enum):


def _handle_kwagrs(kwargs: dict) -> None:
"""Mutates input data"""
"""Mutates input data."""
content_type = _DEFAULT_CONTENT_TYPE

if 'headers' not in kwargs:
Expand All @@ -45,7 +45,7 @@ def _handle_kwagrs(kwargs: dict) -> None:


class ClientBase:
"""Low-level methods are here"""
"""Low-level methods are here."""

def __init__(self, base_url: t.Optional[str] = None, request: t.Optional[Request] = None) -> None:
if request is None:
Expand Down Expand Up @@ -90,7 +90,7 @@ def _invoke(self, invoke_type: InvokeType, **kwargs: t.Any) -> Response:


class AsyncClientBase:
"""Low-level methods are here"""
"""Low-level methods are here."""

def __init__(self, base_url: t.Optional[str] = None, request: t.Optional[AsyncRequest] = None) -> None:
if request is None:
Expand Down
Loading
Loading