Skip to content

Commit

Permalink
Upgrade pyright (#229)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbrattli authored Oct 27, 2024
1 parent 13c2d30 commit efd6d00
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions expression/core/option.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 _:
Expand Down
5 changes: 3 additions & 2 deletions expression/core/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
Literal,
TypeGuard,
TypeVar,
cast,
get_args,
get_origin,
)
Expand Down Expand Up @@ -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]:
Expand Down

0 comments on commit efd6d00

Please sign in to comment.