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

lint and upgrade #122

Merged
merged 3 commits into from
Nov 25, 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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repos:
- id: check-yaml
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.7.2
rev: v0.8.0
hooks:
# Run the linter.
- id: ruff
Expand Down
13 changes: 8 additions & 5 deletions aggrec/aggregates.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from contextlib import suppress
from datetime import datetime, timezone
from enum import Enum
from typing import Annotated, Dict, List
from typing import Annotated
from urllib.parse import urljoin

import bson
Expand Down Expand Up @@ -68,8 +68,8 @@ class AggregateContentType(str, Enum):


class AggregateMetadataResponse(BaseModel):
aggregate_id: str = Field(title="Aggregate identifier")
aggregate_type: AggregateType = Field(title="Aggregate type")
aggregate_id: str = Field(title="Aggregate identifier", example="3b241101-e2bb-4255-8caf-4136c566a962")
aggregate_type: AggregateType = Field(title="Aggregate type", example="application/vnd.apache.parquet")
created: datetime = Field(title="Aggregate creation timestamp")
creator: str = Field(title="Aggregate creator")
headers: dict = Field(title="Dictionary of relevant HTTP headers")
Expand Down Expand Up @@ -103,7 +103,7 @@ def from_db_model(cls, metadata: AggregateMetadata, settings: Settings):
)


def get_http_headers(request: Request, covered_components_headers: List[str]) -> Dict[str, str]:
def get_http_headers(request: Request, covered_components_headers: list[str]) -> dict[str, str]:
"""Get dictionary of relevant metadata HTTP headers"""

relevant_headers = set([header.lower() for header in METADATA_HTTP_HEADERS])
Expand Down Expand Up @@ -282,7 +282,10 @@ async def create_aggregate(
if aggregate_interval:
period = pendulum.parse(aggregate_interval)
if not isinstance(period, pendulum.Interval):
raise HTTPException(status.HTTP_422_UNPROCESSABLE_ENTITY, "Invalid Aggregate-Interval")
raise HTTPException(
status.HTTP_422_UNPROCESSABLE_ENTITY,
"Invalid Aggregate-Interval: must be an ISO 8601 time interval (e.g., '2024-01-01T12:00:00Z/PT1M')",
)
aggregate_interval_start = pendulum_as_datetime(period.start)
aggregate_interval_duration = period.start.diff(period.end).in_seconds()
else:
Expand Down
6 changes: 3 additions & 3 deletions aggrec/settings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from datetime import datetime, timezone
from typing import Annotated, Tuple, Type
from typing import Annotated

from pydantic import AnyHttpUrl, BaseModel, DirectoryPath, Field, UrlConstraints
from pydantic_core import Url
Expand Down Expand Up @@ -57,10 +57,10 @@ class Settings(BaseSettings):
@classmethod
def settings_customise_sources(
cls,
settings_cls: Type[BaseSettings],
settings_cls: type[BaseSettings],
init_settings: PydanticBaseSettingsSource,
env_settings: PydanticBaseSettingsSource,
dotenv_settings: PydanticBaseSettingsSource,
file_secret_settings: PydanticBaseSettingsSource,
) -> Tuple[PydanticBaseSettingsSource, ...]:
) -> tuple[PydanticBaseSettingsSource, ...]:
return (TomlConfigSettingsSource(settings_cls),)
Loading