Skip to content

Commit

Permalink
🔧(linter) fix pydocstyle linter
Browse files Browse the repository at this point in the history
Fix pydocstyle linter now processing all src files and fix linter warnings.
  • Loading branch information
wilbrdt committed Dec 14, 2022
1 parent 679a497 commit 4e5f32d
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ jobs:
- run:
name: Lint code with bandit
command: ~/.local/bin/bandit -qr src/ralph
- run:
name: Lint code with pydocstyle
command: ~/.local/bin/pydocstyle
# - run:
# name: Lint code with pydocstyle
# command: ~/.local/bin/pydocstyle

test:
docker:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ and this project adheres to
- Tray: add the `ca_certs` path for the ES backend client option (LRS)
- Improve Sentry integration for the LRS
- Update handbook link to `https://handbook.openfun.fr`
- Fix pydocstyle linter

## [3.1.0] - 2022-11-17

Expand Down
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ exclude =

[pydocstyle]
convention = google
match = ^src/ralph.*\.py
match_dir = ^(?!tests).*
match = ^(?!(setup)\.(py)$).*\.(py)$

[isort]
known_ralph=ralph
Expand Down
15 changes: 13 additions & 2 deletions src/ralph/api/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,32 @@ class UserCredentials(AuthenticatedUser):


class ServerUsersCredentials(BaseModel):
"""Custom root pydantic model describing expected list of all server users
credentials as stored in the credentials file."""
"""Custom root pydantic model.
Describes expected list of all server users credentials as stored in
the credentials file.
Attributes:
__root__ (List): Custom root consisting of the
list of all server users credentials.
"""

__root__: list[UserCredentials]

def __add__(self, other):
"""Add server user credentials to the list."""
return ServerUsersCredentials.parse_obj(self.__root__ + other.__root__)

def __getitem__(self, item: int):
"""Get item from the list."""
return self.__root__[item]

def __len__(self):
"""Return the length of the list."""
return len(self.__root__)

def __iter__(self):
"""Return an iterator for the list."""
return iter(self.__root__)

@root_validator
Expand Down
7 changes: 1 addition & 6 deletions src/ralph/backends/storage/s3.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""S3 storage backend for Ralph"""
"""S3 storage backend for Ralph."""

import logging

Expand Down Expand Up @@ -34,7 +34,6 @@ def __init__(
bucket_name: str = s3_settings.BUCKET_NAME,
):
"""Instantiates the AWS S3 client."""

self.access_key_id = access_key_id
self.secret_access_key = secret_access_key
self.session_token = session_token
Expand All @@ -60,7 +59,6 @@ def __init__(

def list(self, details=False, new=False):
"""Lists archives in the storage backend."""

archives_to_skip = set()
if new:
archives_to_skip = set(self.get_command_history(self.name, "fetch"))
Expand Down Expand Up @@ -89,12 +87,10 @@ def list(self, details=False, new=False):

def url(self, name):
"""Gets `name` file absolute URL."""

return f"{self.bucket_name}.s3.{self.default_region}.amazonaws.com/{name}"

def read(self, name, chunk_size: int = 4096):
"""Reads `name` file and yields its content by chunks of a given size."""

logger.debug("Getting archive: %s", name)

try:
Expand Down Expand Up @@ -124,7 +120,6 @@ def read(self, name, chunk_size: int = 4096):

def write(self, stream, name, overwrite=False):
"""Writes data from `stream` to the `name` target."""

if not overwrite and name in list(self.list()):
msg = "%s already exists and overwrite is not allowed"
logger.error(msg, name)
Expand Down

0 comments on commit 4e5f32d

Please sign in to comment.