From c05bdc457620ee9a0edab7ee65e26bf4c69dfc34 Mon Sep 17 00:00:00 2001 From: Goldy <66202304+THEGOLDENPRO@users.noreply.github.com> Date: Fri, 22 Dec 2023 22:23:19 +0000 Subject: [PATCH] fix, feat: fixed setuptools bug, added AnimeStaff #2 --- anmoku/resources/anime/__init__.py | 3 +- anmoku/resources/anime/staff.py | 56 +++++++++++++++++++++++++++ anmoku/typing/jikan/anime/__init__.py | 3 +- anmoku/typing/jikan/anime/staff.py | 13 +++++++ pyproject.toml | 6 +-- 5 files changed, 76 insertions(+), 5 deletions(-) create mode 100644 anmoku/resources/anime/staff.py create mode 100644 anmoku/typing/jikan/anime/staff.py diff --git a/anmoku/resources/anime/__init__.py b/anmoku/resources/anime/__init__.py index 85abaee..c27e388 100644 --- a/anmoku/resources/anime/__init__.py +++ b/anmoku/resources/anime/__init__.py @@ -1,2 +1,3 @@ from .anime import * -from .characters import * \ No newline at end of file +from .characters import * +from .staff import * \ No newline at end of file diff --git a/anmoku/resources/anime/staff.py b/anmoku/resources/anime/staff.py new file mode 100644 index 0000000..c8db71f --- /dev/null +++ b/anmoku/resources/anime/staff.py @@ -0,0 +1,56 @@ +from __future__ import annotations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from typing import List + from ...typing.jikan import ( + AnimeStaffData, + JikanResponseData + ) + +from dataclasses import dataclass, field + +from ..helpers import Image +from ..base import JikanResource + +__all__ = ( + "AnimeStaff", +) + +@dataclass +class AnimeIndividualStaff(): + data: AnimeStaffData + + id: int = field(init = False) + """The MyAnimeList ID of this staff.""" + name: str = field(init = False) + """The name of this staff.""" + url: str = field(init = False) + """The MyAnimeList URL to this staff.""" + image: Image = field(init = False) + """The image of this staff.""" + + positions: List[str] = field(init = False) + """The list of positions this staff possess.""" + + def __post_init__(self): + person = self.data["person"] + + self.id = person["mal_id"] + self.name = person["name"] + self.url = person["url"] + self.image = Image(person["images"]) + + self.positions = self.data["positions"] + +@dataclass +class AnimeStaff(JikanResource): + """Get data of the staff from a particular anime.""" + _get_endpoint = "/anime/{id}/staff" + + data: JikanResponseData[List[AnimeStaffData]] + + def __iter__(self): + + for staff in self.data["data"]: + yield AnimeIndividualStaff(staff) \ No newline at end of file diff --git a/anmoku/typing/jikan/anime/__init__.py b/anmoku/typing/jikan/anime/__init__.py index 85abaee..c27e388 100644 --- a/anmoku/typing/jikan/anime/__init__.py +++ b/anmoku/typing/jikan/anime/__init__.py @@ -1,2 +1,3 @@ from .anime import * -from .characters import * \ No newline at end of file +from .characters import * +from .staff import * \ No newline at end of file diff --git a/anmoku/typing/jikan/anime/staff.py b/anmoku/typing/jikan/anime/staff.py new file mode 100644 index 0000000..64326d9 --- /dev/null +++ b/anmoku/typing/jikan/anime/staff.py @@ -0,0 +1,13 @@ +from __future__ import annotations +from typing import TypedDict, final, List + +from ..person import PartialPersonData + +__all__ = ( + "AnimeStaffData", +) + +@final +class AnimeStaffData(TypedDict): + person: PartialPersonData + positions: List[str] \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index b888932..2d4bb95 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,11 +48,11 @@ BugTracker = "https://github.com/THEGOLDENPRO/anmoku/issues" version = { attr = "anmoku.__version__" } [build-system] -requires = ["setuptools", "setuptools-scm"] +requires = ["setuptools"] build-backend = "setuptools.build_meta" -[tool.setuptools] -packages = ["anmoku"] +[tool.setuptools.packages.find] +include = ["anmoku*"] [tool.pytest.ini_options] addopts = [