From 7a6c4039b8d0a502e26a964dc7e6425fc4b9ff15 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 17 Feb 2023 21:50:28 -0800 Subject: [PATCH 1/4] chore: pre-commit autoupdate (#30) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: pre-commit autoupdate updates: - [github.com/psf/black: 22.12.0 → 23.1.0](https://github.com/psf/black/compare/22.12.0...23.1.0) - [github.com/pycqa/isort: 5.11.4 → 5.12.0](https://github.com/pycqa/isort/compare/5.11.4...5.12.0) * style: pre-commit autofix --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 4 ++-- scripts/generate_endpoints.py | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 62506b3..83075f2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,12 +6,12 @@ ci: repos: - repo: https://github.com/psf/black - rev: 22.12.0 + rev: 23.1.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"] diff --git a/scripts/generate_endpoints.py b/scripts/generate_endpoints.py index 2d4a085..2f7e152 100644 --- a/scripts/generate_endpoints.py +++ b/scripts/generate_endpoints.py @@ -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: From 9d67c3eafa0adb6721651d42bf32379afe1df1a4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 16 Jul 2023 14:42:00 -0700 Subject: [PATCH 2/4] chore: pre-commit autoupdate (#31) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 23.1.0 → 23.3.0](https://github.com/psf/black/compare/23.1.0...23.3.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 83075f2..d511233 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,7 +6,7 @@ ci: repos: - repo: https://github.com/psf/black - rev: 23.1.0 + rev: 23.3.0 hooks: - id: black From 2937f7306d3605b7e033658192a39356f513ad0b Mon Sep 17 00:00:00 2001 From: Emre Terzioglu <50607143+EmreTech@users.noreply.github.com> Date: Tue, 18 Jul 2023 23:10:32 -0700 Subject: [PATCH 3/4] refactor: update pyright (#33) * refactor: update pyright to 1.1.317 * fix: pyright errors w/ generate_endpoints * style: pre-commit autofix --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- discatcore/http/client.py | 3 +++ discatcore/utils/event.py | 9 ++++++--- requirements/dev.txt | 2 +- scripts/generate_endpoints.py | 8 +++++--- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/discatcore/http/client.py b/discatcore/http/client.py index f8d4bdc..917f41a 100644 --- a/discatcore/http/client.py +++ b/discatcore/http/client.py @@ -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", diff --git a/discatcore/utils/event.py b/discatcore/utils/event.py index d57a45b..fa4905c 100644 --- a/discatcore/utils/event.py +++ b/discatcore/utils/event.py @@ -57,7 +57,10 @@ def __init__(self, name: str, parent: Dispatcher) -> None: # setters/decorators def set_proto( - self, proto_func: t.Union[Func[t.Any], staticmethod[t.Any]], *, force_parent: bool = False + self, + proto_func: t.Union[Func[t.Any], staticmethod[..., t.Any]], + *, + force_parent: bool = False, ) -> None: """Sets the prototype for this event. @@ -93,7 +96,7 @@ def proto( def proto( self, - func: t.Optional[t.Union[Func[t.Any], staticmethod[t.Any]]] = None, + func: t.Optional[t.Union[Func[t.Any], staticmethod[..., t.Any]]] = None, *, force_parent: bool = False, ) -> t.Union[Event, Callable[[Func[t.Any]], Event]]: @@ -108,7 +111,7 @@ def proto( This depends on if the ``func`` arg was passed in. """ - def wrapper(func: t.Union[Func[t.Any], staticmethod[t.Any]]): + def wrapper(func: t.Union[Func[t.Any], staticmethod[..., t.Any]]): self.set_proto(func, force_parent=force_parent) return self diff --git a/requirements/dev.txt b/requirements/dev.txt index ebf89c6..9bbcd6a 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -1 +1 @@ -pyright==1.1.279 +pyright==1.1.317 diff --git a/scripts/generate_endpoints.py b/scripts/generate_endpoints.py index 2f7e152..7012e2e 100644 --- a/scripts/generate_endpoints.py +++ b/scripts/generate_endpoints.py @@ -273,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)}!") @@ -407,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] = [] From 1c2576a6b0e300093eeb83ced27aa66a0dbd35af Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 18 Jul 2023 23:11:16 -0700 Subject: [PATCH 4/4] chore: pre-commit autoupdate (#32) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 23.3.0 → 23.7.0](https://github.com/psf/black/compare/23.3.0...23.7.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d511233..82c8422 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,7 +6,7 @@ ci: repos: - repo: https://github.com/psf/black - rev: 23.3.0 + rev: 23.7.0 hooks: - id: black