Skip to content

Commit

Permalink
fix, feat: fixed setuptools bug, added AnimeStaff #2
Browse files Browse the repository at this point in the history
  • Loading branch information
THEGOLDENPRO committed Dec 22, 2023
1 parent 44e9c91 commit c05bdc4
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 5 deletions.
3 changes: 2 additions & 1 deletion anmoku/resources/anime/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from .anime import *
from .characters import *
from .characters import *
from .staff import *
56 changes: 56 additions & 0 deletions anmoku/resources/anime/staff.py
Original file line number Diff line number Diff line change
@@ -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)
3 changes: 2 additions & 1 deletion anmoku/typing/jikan/anime/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from .anime import *
from .characters import *
from .characters import *
from .staff import *
13 changes: 13 additions & 0 deletions anmoku/typing/jikan/anime/staff.py
Original file line number Diff line number Diff line change
@@ -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]
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down

0 comments on commit c05bdc4

Please sign in to comment.