Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
Add extra type annotations for dict of variables
Browse files Browse the repository at this point in the history
  • Loading branch information
RLAlpha49 committed May 15, 2024
1 parent 9df19ee commit bf529dc
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 26 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ jobs:
restore-keys: |
${{ runner.os }}-poetry-
- name: Update lock file
run: |
poetry lock
- name: Install dependencies
run: |
poetry install
Expand Down
6 changes: 4 additions & 2 deletions AniLinkPy/apis/anilist/anilist.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Union
from typing import Dict, Union

from AniLinkPy.apis.anilist.custom import CustomRequest
from AniLinkPy.apis.anilist.mutation.mutation import Mutation
Expand Down Expand Up @@ -27,7 +27,9 @@ def __init__(self, auth_token: Union[str, None]) -> None:
self.mutation = Mutation()
self.custom_query = CustomRequest(auth_token)

def custom(self, query: str, variables: dict) -> dict:
def custom(
self, query: str, variables: Union[Dict[str, Union[str, int, bool]]]
) -> dict:
"""
This method is used to send a custom Query or Mutation.
Expand Down
8 changes: 6 additions & 2 deletions AniLinkPy/apis/anilist/custom.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Optional, Union
from typing import Dict, Optional, Union

from AniLinkPy.base.RequestHandler import send_request

Expand All @@ -22,7 +22,11 @@ def __init__(self, auth_token: Union[str, None]) -> None:
self.base_url = "https://graphql.anilist.co"
self.auth_token = auth_token

def custom(self, query: str, variables: Optional[dict] = None) -> dict:
def custom(
self,
query: str,
variables: Optional[Union[Dict[str, Union[str, int, bool]]]] = None,
) -> dict:
"""
This method is used to send a custom Query.
Expand Down
4 changes: 2 additions & 2 deletions AniLinkPy/apis/anilist/query/media.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Union
from typing import Dict, Union

from AniLinkPy.apis.anilist.schemas.query.media_with_relations_schema import (
MEDIAWITHRELATIONSSCHEMA,
Expand All @@ -25,7 +25,7 @@ def __init__(self, auth_token: Union[str, None]) -> None:
self.base_url = "https://graphql.anilist.co"
self.auth_token = auth_token

def media(self, variables: dict) -> dict:
def media(self, variables: Union[Dict[str, Union[str, int, bool]]]) -> dict:
"""
This method is used to send a media Query.
Expand Down
6 changes: 3 additions & 3 deletions AniLinkPy/apis/anilist/query/page/activities.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Union
from typing import Dict, Union

from AniLinkPy.apis.anilist.schemas.activity_schema import ACTIVITYWITHREPLIESSCHEMA
from AniLinkPy.base.RequestHandler import send_request
Expand All @@ -23,7 +23,7 @@ def __init__(self, auth_token: Union[str, None]) -> None:
self.base_url = "https://graphql.anilist.co"
self.auth_token = auth_token

def activities(self, variables: dict) -> dict:
def activities(self, variables: Union[Dict[str, Union[str, int, bool]]]) -> dict:
"""
This method is used to send an activities Query.
Expand All @@ -40,7 +40,7 @@ def activities(self, variables: dict) -> dict:
query = f"""
query ($page: Int, $perPage: Int, $id: Int, $userId: Int, $messengerId: Int, $mediaId: Int,
$type: ActivityType, $isFollowing: Boolean, $hasReplies: Boolean, $hasRepliesOrTypeText: Boolean, $createdAt:
Int, $id_not: Int, $id_in: [Int], $id_not_in: [Int], $userId_not: Int, $userId_in: [Int], $userId_not_in:
Int, $id_not: Int, $id_in: [Int], $id_not_in: [Int], $userId_not: Int, $userId_in: [Int], $userId_not_in: [
Int], $messengerId_not: Int, $messengerId_in: [Int], $messengerId_not_in: [Int], $mediaId_not: Int,
$mediaId_in: [Int], $mediaId_not_in: [Int], $type_not: ActivityType, $type_in: [ActivityType], $type_not_in:
[ActivityType], $createdAt_greater: Int, $sort: [ActivitySort], $asHtml: Boolean) {{ Page (page: $page,
Expand Down
6 changes: 4 additions & 2 deletions AniLinkPy/apis/anilist/query/page/activity_replies.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Union
from typing import Dict, Union

from AniLinkPy.apis.anilist.schemas.activity_schema import ACTIVITYREPLYSCHEMA
from AniLinkPy.base.RequestHandler import send_request
Expand All @@ -23,7 +23,9 @@ def __init__(self, auth_token: Union[str, None]) -> None:
self.base_url = "https://graphql.anilist.co"
self.auth_token = auth_token

def activityReplies(self, variables: dict) -> dict:
def activityReplies(
self, variables: Union[Dict[str, Union[str, int, bool]]]
) -> dict:
"""
This method is used to send an ActivityReplies Query.
Expand Down
6 changes: 4 additions & 2 deletions AniLinkPy/apis/anilist/query/page/airing_schedules.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Union
from typing import Dict, Union

from AniLinkPy.apis.anilist.schemas.query.airing_schedule_schema import (
AIRINGSCHEDULESCHEMA,
Expand All @@ -25,7 +25,9 @@ def __init__(self, auth_token: Union[str, None]) -> None:
self.base_url = "https://graphql.anilist.co"
self.auth_token = auth_token

def airingSchedules(self, variables: dict) -> dict:
def airingSchedules(
self, variables: Union[Dict[str, Union[str, int, bool]]]
) -> dict:
"""
This method is used to send an airingSchedules Query.
Expand Down
14 changes: 10 additions & 4 deletions AniLinkPy/apis/anilist/query/page/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
This module contains the Page class which represents a Page in the AniLink API.
"""

from typing import Union
from typing import Dict, Union

from AniLinkPy.apis.anilist.query.page.activities import ActivitiesQuery
from AniLinkPy.apis.anilist.query.page.activity_replies import ActivityRepliesQuery
Expand All @@ -25,7 +25,9 @@ def __init__(self, auth_token: Union[str, None]) -> None:
self.activity_replies_query = ActivityRepliesQuery(auth_token)
self.airing_schedules_query = AiringSchedulesQuery(auth_token)

def activities(self, variables: Union[dict, None] = None) -> dict:
def activities(
self, variables: Union[Dict[str, Union[str, int, bool]], None] = None
) -> dict:
"""
This method is used to get activities.
Expand All @@ -39,7 +41,9 @@ def activities(self, variables: Union[dict, None] = None) -> dict:
variables = {}
return self.activities_query.activities(variables)

def activityReplies(self, variables: Union[dict, None] = None) -> dict:
def activityReplies(
self, variables: Union[Dict[str, Union[str, int, bool]], None] = None
) -> dict:
"""
This method is used to get activity_replies.
Expand All @@ -53,7 +57,9 @@ def activityReplies(self, variables: Union[dict, None] = None) -> dict:
variables = {}
return self.activity_replies_query.activityReplies(variables)

def airingSchedules(self, variables: Union[dict, None] = None) -> dict:
def airingSchedules(
self, variables: Union[Dict[str, Union[str, int, bool]], None] = None
) -> dict:
"""
This method is used to get airing_schedules.
Expand Down
6 changes: 3 additions & 3 deletions AniLinkPy/apis/anilist/query/query.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Union
from typing import Dict, Union

from AniLinkPy.apis.anilist.query.media import MediaQuery
from AniLinkPy.apis.anilist.query.page.page import Page
Expand All @@ -25,7 +25,7 @@ def __init__(self, auth_token: Union[str, None]) -> None:
self.user_query = UserQuery(auth_token)
self.media_query = MediaQuery(auth_token)

def user(self, variables: dict) -> dict:
def user(self, variables: Union[Dict[str, Union[str, int, bool]]]) -> dict:
"""
This method is used to get a user.
Expand All @@ -37,7 +37,7 @@ def user(self, variables: dict) -> dict:
"""
return self.user_query.user(variables)

def media(self, variables: dict) -> dict:
def media(self, variables: Union[Dict[str, Union[str, int, bool]]]) -> dict:
"""
This method is used to get a media.
Expand Down
4 changes: 2 additions & 2 deletions AniLinkPy/apis/anilist/query/user.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Union
from typing import Dict, Union

from AniLinkPy.apis.anilist.schemas.query.user_schema import USERSCHEMA
from AniLinkPy.base.RequestHandler import send_request
Expand All @@ -23,7 +23,7 @@ def __init__(self, auth_token: Union[str, None]) -> None:
self.base_url = "https://graphql.anilist.co"
self.auth_token = auth_token

def user(self, variables: dict) -> dict:
def user(self, variables: Union[Dict[str, Union[str, int, bool]]]) -> dict:
"""
This method is used to send a user Query.
Expand Down

0 comments on commit bf529dc

Please sign in to comment.