-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix, feat: fixed setuptools bug, added AnimeStaff #2
- Loading branch information
1 parent
44e9c91
commit c05bdc4
Showing
5 changed files
with
76 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters