Skip to content

Commit

Permalink
ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
bisgaard-itis committed Jan 7, 2025
1 parent 6c4f1a6 commit 964bb67
Show file tree
Hide file tree
Showing 16 changed files with 23 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ def get_settings(request: Request) -> ApplicationSettings:
assert get_app # nosec

__all__: tuple[str, ...] = (
"get_reverse_url_mapper",
"get_app",
"get_reverse_url_mapper",
)
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ async def list_files(

file_meta: File = to_file_api_model(stored_file_meta)

except (ValidationError, ValueError, AttributeError) as err: # noqa: PERF203
except (ValidationError, ValueError, AttributeError) as err:
_logger.warning(
"Skipping corrupted entry in storage '%s' (%s)"
"TIP: check this entry in file_meta_data table.",
Expand Down Expand Up @@ -186,7 +186,7 @@ async def upload_file(
file_meta: File = await File.create_from_uploaded(
file,
file_size=file_size,
created_at=datetime.datetime.now(datetime.timezone.utc).isoformat(),
created_at=datetime.datetime.now(datetime.UTC).isoformat(),
)
_logger.debug(
"Assigned id: %s of %s bytes (content-length), real size %s bytes",
Expand Down Expand Up @@ -242,7 +242,7 @@ async def get_upload_links(
assert request # nosec
file_meta: File = await File.create_from_client_file(
client_file,
datetime.datetime.now(datetime.timezone.utc).isoformat(),
datetime.datetime.now(datetime.UTC).isoformat(),
)
_, upload_links = await get_upload_links_from_s3(
user_id=user_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async def check_service_health(
status_code=status.HTTP_503_SERVICE_UNAVAILABLE, detail="unhealthy"
)

return f"{__name__}@{datetime.datetime.now(tz=datetime.timezone.utc).isoformat()}"
return f"{__name__}@{datetime.datetime.now(tz=datetime.UTC).isoformat()}"


@router.get(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ async def _background_task_method(self):
self._dummy_queue.get(), timeout=self._timeout_seconds
)
self._health_check_failure_count = 0
except asyncio.TimeoutError:
except TimeoutError:
self._increment_health_check_failure_count()


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
from simcore_postgres_database.models.users import UserRole, UserStatus, users

__all__: tuple[str, ...] = (
"GroupType",
"UserRole",
"UserStatus",
"api_keys",
"groups",
"GroupType",
"metadata",
"user_to_groups",
"UserRole",
"users",
"UserStatus",
)

# nopycln: file # noqa: ERA001
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Any, Awaitable, Callable, TypeAlias
from collections.abc import Awaitable, Callable
from typing import Any, TypeAlias

from fastapi.encoders import jsonable_encoder
from fastapi.requests import Request
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ def _check_total(cls, v, info: ValidationInfo):


__all__: tuple[str, ...] = (
"PaginationParams",
"MAXIMUM_NUMBER_OF_ITEMS_PER_PAGE",
"OnePage",
"Page",
"PaginationParams",
)
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class File(BaseModel):
# WARNING: from pydantic import File as FileParam
# NOTE: see https://ant.apache.org/manual/Tasks/checksum.html

id: UUID = Field(..., description="Resource identifier") # noqa: A003
id: UUID = Field(..., description="Resource identifier")

filename: str = Field(..., description="Name of the file with extension")
content_type: str | None = Field(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ class JobMetadata(BaseModel):


class Job(BaseModel):
id: JobID # noqa: A003
id: JobID
name: RelativeResourceName

inputs_checksum: str = Field(..., description="Input's checksum")
Expand Down Expand Up @@ -248,7 +248,7 @@ def create_now(
id=global_uuid,
runner_name=parent_name,
inputs_checksum=inputs_checksum,
created_at=datetime.datetime.now(tz=datetime.timezone.utc),
created_at=datetime.datetime.now(tz=datetime.UTC),
url=None,
runner_url=None,
outputs_url=None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ async def list_solvers(
if predicate is None or predicate(solver):
solvers.append(solver)

except ValidationError as err: # noqa: PERF203
except ValidationError as err:
# NOTE: For the moment, this is necessary because there are no guarantees
# at the image registry. Therefore we exclude and warn
# invalid items instead of returning error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import urllib.parse
import uuid
from collections.abc import Callable
from datetime import datetime, timezone
from datetime import UTC, datetime
from functools import lru_cache

import arrow
Expand Down Expand Up @@ -45,7 +45,7 @@ def format_datetime(snapshot: datetime) -> str:

def now_str() -> str:
# NOTE: backend MUST use UTC
return format_datetime(datetime.now(timezone.utc))
return format_datetime(datetime.now(UTC))


# CONVERTERS --------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ def setup(


__all__: tuple[str, ...] = (
"setup",
"StorageApi",
"StorageFileMetaData",
"setup",
"to_file_api_model",
)
2 changes: 1 addition & 1 deletion services/api-server/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
import sys
from pathlib import Path

from pydantic import TypeAdapter
import pytest
import simcore_service_api_server
from dotenv import dotenv_values
from models_library.projects import ProjectID
from pydantic import TypeAdapter
from pytest_simcore.helpers.monkeypatch_envs import EnvVarsDict
from simcore_service_api_server.models.schemas.jobs import JobID

Expand Down
2 changes: 1 addition & 1 deletion services/api-server/tests/unit/_with_db/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def docker_compose_file(
# configs
subprocess.run(
f'docker compose --file "{src_path}" config > "{dst_path}"',
shell=True, # noqa: S602
shell=True,
check=True,
env=environ,
)
Expand Down
2 changes: 1 addition & 1 deletion services/api-server/tests/unit/test_api_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def file(cls) -> File:
id=File.create_id(
cls._file_size,
cls._file_name,
datetime.datetime.now(datetime.timezone.utc).isoformat(),
datetime.datetime.now(datetime.UTC).isoformat(),
),
filename=cls._file_name,
e_tag="",
Expand Down
2 changes: 1 addition & 1 deletion services/api-server/tests/unit/test_licensed_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ async def test_get_licensed_items_timeout(
):
mock_wb_api_server_rcp.patch(
"simcore_service_api_server.services_rpc.wb_api_server._get_licensed_items",
partial(_get_backend_licensed_items, exception_to_raise=asyncio.TimeoutError()),
partial(_get_backend_licensed_items, exception_to_raise=TimeoutError()),
)
resp = await client.get(f"{API_VTAG}/licensed-items", auth=auth)
assert resp.status_code == status.HTTP_504_GATEWAY_TIMEOUT
Expand Down

0 comments on commit 964bb67

Please sign in to comment.