Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update pyright #219

Merged
merged 4 commits into from
Aug 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.363"]
additional_dependencies: ["pyright@1.1.374"]
repo: local
2 changes: 1 addition & 1 deletion expression/collections/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ def sum(self: TypedArray[_TSourceSum]) -> int:
def sum_by(self, projection: Callable[[_TSource], _TSourceSum]) -> int:
return pipe(
self,
sum_by(projection), # type: ignore
sum_by(projection),
)

def tail(self) -> TypedArray[_TSource]:
Expand Down
2 changes: 1 addition & 1 deletion expression/collections/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def of_seq(sequence: Iterable[tuple[_Key_, _Result]]) -> Map[_Key_, _Result]:
"""
return of_seq(sequence)

def __hash__(self) -> int: # type: ignore
def __hash__(self) -> int:
def combine_hash(x: int, y: int) -> int:
return (x << 1) + y + 631

Expand Down
8 changes: 4 additions & 4 deletions expression/core/tagged_union.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def tagged_union(

def transform(cls: Any) -> Any:
cls = dataclass(init=False, repr=False, order=False, eq=False, kw_only=True)(cls)
fields_ = fields(cls) # type: ignore
fields_ = fields(cls)
field_names = tuple(f.name for f in fields_)
original_init = cls.__init__

Expand All @@ -65,7 +65,7 @@ def __init__(self: Any, **kwargs: Any) -> None:

# Enables the use of dataclasses.asdict
union_fields = dict((f.name, f) for f in fields_ if f.name in [name, "tag"])
object.__setattr__(self, "__dataclass_fields__", union_fields) # type: ignore
object.__setattr__(self, "__dataclass_fields__", union_fields)
original_init(self)

def __repr__(self: Any) -> str:
Expand All @@ -77,9 +77,9 @@ def __lt__(self: Any, other: Any) -> bool:
if not isinstance(other, cls):
return False

return (self._index, getattr(self, self.tag)) < (other._index, getattr(other, other.tag)) # type: ignore
return (self._index, getattr(self, self.tag)) < (other._index, getattr(other, other.tag))

cls.__lt__ = __lt__ # type: ignore
cls.__lt__ = __lt__

if frozen:

Expand Down
5 changes: 2 additions & 3 deletions expression/core/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from abc import abstractmethod
from collections.abc import Iterable
from typing import Any, Protocol, TypeVar, cast, get_origin
from typing import Any, Protocol, TypeVar, get_origin


_T = TypeVar("_T")
Expand Down Expand Up @@ -88,8 +88,7 @@ def try_downcast(type_: type[_Derived], expr: Any) -> _Derived | None:
"""
origin: type[_Derived] | None = get_origin(type_) or type_
if origin is not None and isinstance(expr, origin):
derived = cast(_Derived, expr)
return derived
return expr

return None

Expand Down
2 changes: 1 addition & 1 deletion expression/extra/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def cons(head: _A, tail: Block[_A]) -> Block[_A]:
match parser_list:
case block.empty:
return preturn(block.empty)
case Block([head, *tail]): # type: ignore
case Block([head, *tail]):
tail_ = sequence(Block(tail))
return cons_p(head)(tail_)
case _:
Expand Down
Loading