Skip to content

Commit

Permalink
chore: format
Browse files Browse the repository at this point in the history
  • Loading branch information
Ravencentric committed Jul 4, 2024
1 parent f091389 commit 9e88100
Show file tree
Hide file tree
Showing 12 changed files with 468 additions and 474 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.5
rev: v0.5.0
hooks:
- id: ruff
args: ['--fix']
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.5
rev: v0.5.0
hooks:
- id: ruff-format
- repo: https://github.com/python-poetry/poetry
Expand Down
875 changes: 429 additions & 446 deletions poetry.lock

Large diffs are not rendered by default.

27 changes: 14 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,30 @@ classifiers = [

[tool.poetry.dependencies]
python = ">=3.9"
pydantic = "^2.8.0"
typing-extensions =">=4.11.0"
pydantic-extra-types =">=2.7.0"
pycountry = ">=23.12.11"
pydantic = ">=2.8.2"
typing-extensions =">=4.12.2"
pydantic-extra-types =">=2.9.0"
pycountry = ">=24.6.1"
httpx = ">=0.27.0"
boltons = ">=24.0.0"
stamina = ">=24.2.0"
nh3 = "^0.2.17"
html2text = "^2024.2.26"
importlib-metadata = { version = ">=7.1.0", python = "<3.10" }
nh3 = ">=0.2.17"
html2text = ">=2024.2.26"
importlib-metadata = { version = ">=8.0.0", python = "<3.10" }
eval-type-backport = { version = ">=0.2.0", python = "<3.10" }
backports-strenum = {version = ">=1.3.1", python = "<3.11"}

[tool.poetry.group.dev.dependencies]
ruff = "^0.3.5"
mypy = "^1.9.0"
ruff = "^0.5.0"
mypy = "^1.10.1"
types-boltons = "^23.1.0.20240331"
pytest = "^8.1.1"
pytest = "^8.2.2"
pytest-asyncio = "^0.23.5.post1"
pre-commit = "^3.7.0"
coverage = "^7.5.0"
pre-commit = "^3.7.1"
coverage = "^7.5.4"

[tool.poetry.group.docs.dependencies]
mkdocs-material = "^9.5.18"
mkdocs-material = "^9.5.28"
mkdocstrings = {extras = ["python"], version = "^0.24.0"}
mkdocs-autorefs = "^1.0.1"

Expand All @@ -59,6 +59,7 @@ fixable = ["ALL"]
[tool.mypy]
strict = true
pretty = true
exclude = "/tests/"

[tool.pytest.ini_options]
asyncio_mode = "auto"
Expand Down
6 changes: 2 additions & 4 deletions src/pyanilist/_clients/_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@

class AniList:
@validate_call
def __init__(
self, api_url: str = "https://graphql.anilist.co", retries: PositiveInt = 5, **kwargs: Any
) -> None:
def __init__(self, api_url: str = "https://graphql.anilist.co", retries: PositiveInt = 5, **kwargs: Any) -> None:
"""
AniList API client.
Expand Down Expand Up @@ -69,7 +67,7 @@ def _post_request(self, **kwargs: Any) -> Response:
with attempt:
with Client(**self.kwargs) as client:
response = client.post(self.api_url, json=payload).raise_for_status()

return response

@validate_call
Expand Down
1 change: 1 addition & 0 deletions src/pyanilist/_compat.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Compatibility module to for older python versions"""

from __future__ import annotations

import sys
Expand Down
2 changes: 1 addition & 1 deletion src/pyanilist/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def iso_format(self) -> str:

else:
return ""

def as_int(self) -> FuzzyDateInt:
"""
Return an 8 digit long date integer (YYYYMMDD).
Expand Down
6 changes: 4 additions & 2 deletions src/pyanilist/_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

from ._utils import flatten, markdown_formatter, remove_null_fields, sanitize_description, text_formatter

if TYPE_CHECKING: # pragma: no cover
if TYPE_CHECKING: # pragma: no cover
from httpx import Response


def process_description(dictionary: dict[str, Any]) -> dict[str, Any]:
"""
Anilist's description field takes a parameter `asHtml: boolean`, effectively
Expand Down Expand Up @@ -60,6 +61,7 @@ def process_description(dictionary: dict[str, Any]) -> dict[str, Any]:
text=text_description,
)


def post_process_response(response: Response) -> dict[str, Any]:
"""
Post-processes the response from AniList API.
Expand Down Expand Up @@ -122,4 +124,4 @@ def post_process_response(response: Response) -> dict[str, Any]:

# self explanatory, details on why
# are in the function docstring
return remove_null_fields(dictionary)
return remove_null_fields(dictionary)
5 changes: 3 additions & 2 deletions src/pyanilist/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def remove_null_fields(dictionary: dict[str, Any]) -> dict[str, Any]:
"""
return remap(dictionary, lambda path, key, value: value not in [None, {}, []]) # type: ignore


def query_variables_constructor(vars: dict[str, Any]) -> dict[str, Any]:
"""
Anilist doesn't stick to a single casing.
Expand Down Expand Up @@ -179,11 +180,11 @@ def query_variables_constructor(vars: dict[str, Any]) -> dict[str, Any]:
}

query_vars = {}

for key, value in vars.items():
if value is not None:
if isinstance(value, Iterable) and not isinstance(value, str):
value = set(value)
query_vars[casing[key]] = value

return query_vars
return query_vars
1 change: 1 addition & 0 deletions src/pyanilist/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class Version(NamedTuple):
minor: int
micro: int


def _get_version() -> str:
"""
Get the version of pyanilist
Expand Down
2 changes: 1 addition & 1 deletion tests/test_anilist.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def test_anilist_with_constraints() -> None:
("Katsuyuki Kodera", "Storyboard (eps 5, 9, 13)"),
("Kenji Nagasaki", "Storyboard (OP, ED, eps 1, 2)"),
]
assert media.site_url.__str__() =="https://anilist.co/anime/21459"
assert media.site_url.__str__() == "https://anilist.co/anime/21459"


def test_anilist_id() -> None:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ def test_fuzzy_date() -> None:
assert FuzzyDate(year=2023, month=1).as_int() == 20230100
assert FuzzyDate(year=2023).as_int() == 20230000

assert FuzzyDate().iso_format() == ""
assert FuzzyDate().iso_format() == ""
11 changes: 9 additions & 2 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
from pyanilist._utils import flatten, markdown_formatter, remove_null_fields, sanitize_description, text_formatter, query_variables_constructor
from pyanilist import MediaSource
from pyanilist._utils import (
flatten,
markdown_formatter,
query_variables_constructor,
remove_null_fields,
sanitize_description,
text_formatter,
)

from .mock_descriptions import BloomIntoYouAnthologyDescriptions

Expand Down Expand Up @@ -123,4 +130,4 @@ def test_query_variables_constructor() -> None:
"search": "Attack on Titan",
"id_not_in": {1, 2, 3, 4, 5},
"source_in": {MediaSource.ANIME, MediaSource.MANGA},
}
}

0 comments on commit 9e88100

Please sign in to comment.