Skip to content
This repository has been archived by the owner on Jul 20, 2023. It is now read-only.

Commit

Permalink
Merge branch 'main' into refactor/dispatcher-rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
EmreTech committed Jul 19, 2023
2 parents e0ba017 + 1c2576a commit 7760ea8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ ci:
repos:
- repo: https://github.com/psf/black
rev: 22.12.0
rev: 23.7.0
hooks:
- id: black

- repo: https://github.com/pycqa/isort
rev: 5.11.4
rev: 5.12.0
hooks:
- id: isort
args: ["--profile", "black", "--filter-files"]
Expand Down
3 changes: 3 additions & 0 deletions discatcore/http/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ def _prepare_data(
pd.json = _filter_dict_for_unset(json) if isinstance(json, dict) else json

if json is not Unset and files is not Unset:
if t.TYPE_CHECKING:
files = t.cast(list[BasicFile], files)

form_dat = aiohttp.FormData()
form_dat.add_field(
"payload_json",
Expand Down
2 changes: 1 addition & 1 deletion requirements/dev.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pyright==1.1.279
pyright==1.1.317
9 changes: 6 additions & 3 deletions scripts/generate_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class UnsetType(Enum):
# Function Creator
#


# taken from typing
# https://github.com/python/cpython/blob/3.10/Lib/typing.py#L185-L203
def _type_repr(obj: t.Any) -> str:
Expand Down Expand Up @@ -272,7 +273,9 @@ def _dict_type_check(
elif val is ...:
return Unset

if isinstance(val, expected_type):
origin = t.get_origin(expected_type)

if isinstance(val, origin or expected_type):
return val
raise TypeError(f"the value at key {key} is not of type {_type_repr(expected_type)}!")

Expand Down Expand Up @@ -406,8 +409,8 @@ def parse_endpoint_func(name: str, func: dict[str, t.Any]) -> tuple[str, list[st
def parse_json_file(file: dict[str, t.Any]) -> str:
funcs: list[str] = []
name = _dict_type_check(file, "name", str)
methods: dict[str, t.Any] = _dict_type_check(file, "methods", dict)
requires: UnsetOr[list[str]] = _dict_type_check(file, "requires", list, is_required=False)
methods: dict[str, t.Any] = _dict_type_check(file, "methods", dict[str, t.Any])
requires: UnsetOr[list[str]] = _dict_type_check(file, "requires", list[str], is_required=False)

imports = ""
used_imports: list[str] = []
Expand Down

0 comments on commit 7760ea8

Please sign in to comment.