Skip to content

Commit

Permalink
updated ruff, and updated code accordingly
Browse files Browse the repository at this point in the history
  • Loading branch information
TeKrop committed Nov 23, 2024
1 parent 732e771 commit 2493ef3
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 83 deletions.
8 changes: 1 addition & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,10 @@ default_language_version:
python: python3.12
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.2
rev: v0.8.0
hooks:
- id: ruff
name: (ruff) Linting and fixing code
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format
name: (ruff) Formatting code
- repo: https://github.com/sourcery-ai/sourcery
rev: v1.23.0
hooks:
- id: sourcery
name: (sourcery) Checking code quality
args: [--diff=git diff HEAD, --no-summary]
14 changes: 10 additions & 4 deletions app/heroes/router.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Heroes endpoints router : heroes list, heroes details, etc."""

from typing import Annotated

from fastapi import APIRouter, Path, Query, Request, status

from app.enums import Locale, RouteTag
Expand Down Expand Up @@ -27,8 +29,10 @@
)
async def list_heroes(
request: Request,
role: Role = Query(None, title="Role filter"),
locale: Locale = Query(Locale.ENGLISH_US, title="Locale to be displayed"),
role: Annotated[Role | None, Query(title="Role filter")] = None,
locale: Annotated[
Locale, Query(title="Locale to be displayed")
] = Locale.ENGLISH_US,
) -> list[HeroShort]:
return await ListHeroesController(request).process_request(
role=role,
Expand All @@ -55,8 +59,10 @@ async def list_heroes(
)
async def get_hero(
request: Request,
hero_key: HeroKey = Path(title="Key name of the hero"),
locale: Locale = Query(Locale.ENGLISH_US, title="Locale to be displayed"),
hero_key: Annotated[HeroKey, Path(title="Key name of the hero")],
locale: Annotated[
Locale, Query(title="Locale to be displayed")
] = Locale.ENGLISH_US,
) -> Hero:
return await GetHeroController(request).process_request(
hero_key=hero_key,
Expand Down
14 changes: 9 additions & 5 deletions app/maps/router.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Maps endpoints router : maps list, etc."""

from typing import Annotated

from fastapi import APIRouter, Query, Request

from app.enums import RouteTag
Expand All @@ -23,10 +25,12 @@
)
async def list_maps(
request: Request,
gamemode: MapGamemode = Query(
None,
title="Gamemode filter",
description="Filter maps available for a specific gamemode",
),
gamemode: Annotated[
MapGamemode | None,
Query(
title="Gamemode filter",
description="Filter maps available for a specific gamemode",
),
] = None,
) -> list[Map]:
return await ListMapsController(request).process_request(gamemode=gamemode)
1 change: 0 additions & 1 deletion app/players/parsers/player_career_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class PlayerCareerParser(BasePlayerParser):
"""Overwatch player profile page Parser class"""

root_path = settings.career_path
timeout = settings.career_path_cache_timeout
valid_http_codes: ClassVar[list] = [
200, # Classic response
404, # Player Not Found response, we want to handle it here
Expand Down
91 changes: 52 additions & 39 deletions app/players/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,22 @@ async def get_player_career_common_parameters(
)
async def search_players(
request: Request,
name: str = Query(
title="Player nickname to search",
examples=["TeKrop"],
),
order_by: str = Query(
"name:asc",
title="Ordering field and the way it's arranged (asc[ending]/desc[ending])",
pattern=r"^(player_id|name|last_updated_at):(asc|desc)$",
),
offset: int = Query(0, title="Offset of the results", ge=0),
limit: int = Query(20, title="Limit of results per page", gt=0),
name: Annotated[
str,
Query(
title="Player nickname to search",
examples=["TeKrop"],
),
],
order_by: Annotated[
str,
Query(
title="Ordering field and the way it's arranged (asc[ending]/desc[ending])",
pattern=r"^(player_id|name|last_updated_at):(asc|desc)$",
),
] = "name:asc",
offset: Annotated[int, Query(title="Offset of the results", ge=0)] = 0,
limit: Annotated[int, Query(title="Limit of results per page", gt=0)] = 20,
) -> PlayerSearchResult:
return await SearchPlayersController(request).process_request(
name=name,
Expand Down Expand Up @@ -172,24 +177,28 @@ async def get_player_summary(
async def get_player_stats_summary(
request: Request,
commons: CommonsPlayerDep,
gamemode: PlayerGamemode = Query(
None,
title="Gamemode",
description=(
"Filter on a specific gamemode. If not specified, the data of "
"every gamemode will be combined."
gamemode: Annotated[
PlayerGamemode | None,
Query(
title="Gamemode",
description=(
"Filter on a specific gamemode. If not specified, the data of "
"every gamemode will be combined."
),
examples=["competitive"],
),
examples=["competitive"],
),
platform: PlayerPlatform = Query(
None,
title="Platform",
description=(
"Filter on a specific platform. If not specified, the data of "
"every platform will be combined."
] = None,
platform: Annotated[
PlayerPlatform | None,
Query(
title="Platform",
description=(
"Filter on a specific platform. If not specified, the data of "
"every platform will be combined."
),
examples=["pc"],
),
examples=["pc"],
),
] = None,
) -> PlayerStatsSummary:
return await GetPlayerStatsSummaryController(request).process_request(
player_id=commons.get("player_id"),
Expand Down Expand Up @@ -260,18 +269,22 @@ async def get_player_stats(
async def get_player_career(
request: Request,
commons: CommonsPlayerDep,
gamemode: PlayerGamemode = Query(
None,
title="Gamemode",
description="Filter on a specific gamemode. All gamemodes are displayed by default.",
examples=["competitive"],
),
platform: PlayerPlatform = Query(
None,
title="Platform",
description="Filter on a specific platform. All platforms are displayed by default.",
examples=["pc"],
),
gamemode: Annotated[
PlayerGamemode | None,
Query(
title="Gamemode",
description="Filter on a specific gamemode. All gamemodes are displayed by default.",
examples=["competitive"],
),
] = None,
platform: Annotated[
PlayerPlatform | None,
Query(
title="Platform",
description="Filter on a specific platform. All platforms are displayed by default.",
examples=["pc"],
),
] = None,
) -> Player:
return await GetPlayerCareerController(request).process_request(
player_id=commons.get("player_id"),
Expand Down
6 changes: 5 additions & 1 deletion app/roles/router.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Roles endpoints router : roles list, etc."""

from typing import Annotated

from fastapi import APIRouter, Query, Request

from app.enums import Locale, RouteTag
Expand All @@ -24,6 +26,8 @@
)
async def list_roles(
request: Request,
locale: Locale = Query(Locale.ENGLISH_US, title="Locale to be displayed"),
locale: Annotated[
Locale, Query(title="Locale to be displayed")
] = Locale.ENGLISH_US,
) -> list[RoleDetail]:
return await ListRolesController(request).process_request(locale=locale)
8 changes: 5 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "overfast-api"
version = "3.6.0"
version = "3.6.1"
description = "Overwatch API giving data about heroes, maps, and players statistics."
license = {file = "LICENSE"}
authors = [
Expand Down Expand Up @@ -34,7 +34,7 @@ dev-dependencies = [
"pytest-cov==6.0.*",
"pytest-randomly==3.16.*",
"pytest-xdist==3.6.*",
"ruff==0.7.*",
"ruff==0.8.*",
"pre-commit==4.0.*",
"pyinstrument>=5.0.0",
"memray>=1.14.0",
Expand All @@ -61,6 +61,7 @@ select = [
"S", # flake8-bandit
"BLE", # flake8-blind-except
"B", # flake8-bugbear
"A", # flake8-builtins
"COM", # flake8-commas
"C4", # flake8-comprehensions
"DTZ", # flake8-datetimez
Expand All @@ -72,6 +73,7 @@ select = [
"INT", # flake8-gettext
"ISC", # flake8-implicit-str-concat
"ICN", # flake8-import-conventions
"LOG", # flake8-logging
"G", # flake8-logging-format
"INP", # flake8-no-pep420
"PIE", # flake8-pie
Expand All @@ -85,7 +87,6 @@ select = [
"SLOT", # flake8-slots
"SIM", # flake8-simplify
"TID", # flake8-tidy-imports
"TD", # flake8-todos
"TCH", # flake8-type-checking
"ARG", # flake8-unused-arguments
"PTH", # flake8-use-pathlib
Expand All @@ -94,6 +95,7 @@ select = [
"PL", # pylint
"TRY", # tryceratops
"FLY", # flynt
"FAST", # FastAPI rules
"PERF", # perflint
"FURB", # refurb
"RUF", # ruff-specific rules
Expand Down
46 changes: 23 additions & 23 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2493ef3

Please sign in to comment.