From efd6d00b78a315af8ca5bbf3076324d23d787f4d Mon Sep 17 00:00:00 2001 From: Dag Brattli Date: Sun, 27 Oct 2024 19:39:44 +0100 Subject: [PATCH] Upgrade pyright (#229) --- .github/workflows/python-package.yml | 2 +- .pre-commit-config.yaml | 2 +- expression/core/option.py | 4 ++-- expression/core/result.py | 5 +++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 518607a..58ac388 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.10", "3.11", "3.12"] + python-version: ["3.10", "3.11", "3.12", "3.13"] steps: - uses: actions/checkout@v3 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fa33c30..1dcdeb1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,5 +14,5 @@ repos: language: node pass_filenames: false types: [python] - additional_dependencies: ["pyright@1.1.374"] + additional_dependencies: ["pyright@1.1.386"] repo: local diff --git a/expression/core/option.py b/expression/core/option.py index eacc0dc..2085ad1 100644 --- a/expression/core/option.py +++ b/expression/core/option.py @@ -10,7 +10,7 @@ import builtins from collections.abc import Callable, Generator, Iterable -from typing import TYPE_CHECKING, Any, Literal, TypeGuard, TypeVar, get_args, get_origin +from typing import TYPE_CHECKING, Any, Literal, TypeGuard, TypeVar, cast, get_args, get_origin from typing_extensions import TypeVarTuple, Unpack @@ -258,7 +258,7 @@ def dict(self) -> _TSourceOut | None: case Option(tag="some", some=value): attr = getattr(value, "model_dump", None) or getattr(value, "dict", None) if attr and callable(attr): - value = attr() + value = cast(_TSourceOut, attr()) return value case _: diff --git a/expression/core/result.py b/expression/core/result.py index 23acbf7..0bbe099 100644 --- a/expression/core/result.py +++ b/expression/core/result.py @@ -20,6 +20,7 @@ Literal, TypeGuard, TypeVar, + cast, get_args, get_origin, ) @@ -189,12 +190,12 @@ def dict(self) -> builtins.dict[str, _TSourceOut | _TError | Literal["ok", "erro case Result(tag="ok", ok=value): attr = getattr(value, "model_dump", None) or getattr(value, "dict", None) if attr and callable(attr): - value = attr() + value = cast(_TSourceOut, attr()) return {"tag": "ok", "ok": value} case Result(error=error): attr = getattr(error, "model_dump", None) or getattr(error, "dict", None) if attr and callable(attr): - error = attr() + error = cast(_TError, attr()) return {"tag": "error", "error": error} def swap(self) -> Result[_TError, _TSourceOut]: