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 ruff #218

Merged
merged 5 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 @@ -6,7 +6,7 @@ repos:
- id: ruff-format
args: [--check]
repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.11
rev: v0.5.6
- hooks:
- id: pyright
name: pyright
Expand Down
1 change: 1 addition & 0 deletions expression/collections/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Collection abstractions."""

from . import array, asyncseq, block, map, seq
from .array import TypedArray
from .block import Block
Expand Down
34 changes: 12 additions & 22 deletions expression/collections/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
type of input.

"""

from __future__ import annotations

import array
Expand Down Expand Up @@ -39,48 +40,37 @@
_Array = list[_TSourceSum] | MutableSequence[_TSourceSum]


class int8(int):
...
class int8(int): ...


class int16(int):
...
class int16(int): ...


class int32(int):
...
class int32(int): ...


class int64(int):
...
class int64(int): ...


class uint8(int):
...
class uint8(int): ...


class uint16(int):
...
class uint16(int): ...


class uint32(int):
...
class uint32(int): ...


class uint64(int):
...
class uint64(int): ...


class float32(float):
...
class float32(float): ...


class float64(float):
...
class float64(float): ...


class double(float):
...
class double(float): ...


class TypeCode(Enum):
Expand Down
18 changes: 6 additions & 12 deletions expression/collections/asyncseq.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,15 @@ def empty(cls) -> AsyncIterable[Any]:

@overload
@classmethod
def range(cls, stop: int) -> AsyncIterable[int]:
...
def range(cls, stop: int) -> AsyncIterable[int]: ...

@overload
@classmethod
def range(cls, start: int, stop: int) -> AsyncIterable[int]:
...
def range(cls, start: int, stop: int) -> AsyncIterable[int]: ...

@overload
@classmethod
def range(cls, start: int, stop: int, step: int) -> AsyncIterable[int]:
...
def range(cls, start: int, stop: int, step: int) -> AsyncIterable[int]: ...

@classmethod
def range(cls, *args: Any, **kw: Any) -> AsyncIterable[int]:
Expand Down Expand Up @@ -67,18 +64,15 @@ async def repeat(value: TSource, times: int | None = None) -> AsyncIterable[TSou


@overload
def range(stop: int) -> AsyncIterable[int]:
...
def range(stop: int) -> AsyncIterable[int]: ...


@overload
def range(start: int, stop: int) -> AsyncIterable[int]:
...
def range(start: int, stop: int) -> AsyncIterable[int]: ...


@overload
def range(start: int, stop: int, step: int) -> AsyncIterable[int]:
...
def range(start: int, stop: int, step: int) -> AsyncIterable[int]: ...


async def range(*args: int, **kw: int) -> AsyncIterable[int]:
Expand Down
25 changes: 9 additions & 16 deletions expression/collections/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
... block.filter(lambda x: x<10)
... )
"""

from __future__ import annotations

import builtins
Expand Down Expand Up @@ -316,18 +317,15 @@ def partition(self, predicate: Callable[[_TSource], bool]) -> tuple[Block[_TSour

@overload
@staticmethod
def range(stop: int) -> Block[int]:
...
def range(stop: int) -> Block[int]: ...

@overload
@staticmethod
def range(start: int, stop: int) -> Block[int]:
...
def range(start: int, stop: int) -> Block[int]: ...

@overload
@staticmethod
def range(start: int, stop: int, step: int) -> Block[int]:
...
def range(start: int, stop: int, step: int) -> Block[int]: ...

@staticmethod
def range(*args: int, **kw: int) -> Block[int]:
Expand Down Expand Up @@ -497,12 +495,10 @@ def __contains__(self, value: Any) -> bool:
return False

@overload
def __getitem__(self, key: slice) -> Block[_TSource]:
...
def __getitem__(self, key: slice) -> Block[_TSource]: ...

@overload
def __getitem__(self, key: int) -> _TSource:
...
def __getitem__(self, key: int) -> _TSource: ...

def __getitem__(self, key: Any) -> Any:
ret: Any = self._value[key]
Expand Down Expand Up @@ -840,18 +836,15 @@ def partition(


@overload
def range(stop: int) -> Block[int]:
...
def range(stop: int) -> Block[int]: ...


@overload
def range(start: int, stop: int) -> Block[int]:
...
def range(start: int, stop: int) -> Block[int]: ...


@overload
def range(start: int, stop: int, step: int) -> Block[int]:
...
def range(start: int, stop: int, step: int) -> Block[int]: ...


def range(*args: int, **kw: int) -> Block[int]:
Expand Down
1 change: 1 addition & 0 deletions expression/collections/maptree.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

Do not use directly. Use the `map` module instead.
"""

import builtins
from collections.abc import Callable, Iterable, Iterator
from dataclasses import dataclass
Expand Down
37 changes: 13 additions & 24 deletions expression/collections/seq.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
>>> xs = Seq([1, 2, 3])
>>> ys = xs.map(lambda x: x + 1).filter(lambda x: x < 3)
"""

from __future__ import annotations

import builtins
Expand Down Expand Up @@ -175,22 +176,19 @@ def map(self, mapper: Callable[[_TSource], _TResult]) -> Seq[_TResult]:
return Seq(pipe(self, map(mapper)))

@overload
def starmap(self: Seq[tuple[_T1, _T2]], mapping: Callable[[_T1, _T2], _TResult]) -> Seq[_TResult]:
...
def starmap(self: Seq[tuple[_T1, _T2]], mapping: Callable[[_T1, _T2], _TResult]) -> Seq[_TResult]: ...

@overload
def starmap(
self: Seq[tuple[_T1, _T2, _T3]],
mapping: Callable[[_T1, _T2, _T3], _TResult],
) -> Seq[_TResult]:
...
) -> Seq[_TResult]: ...

@overload
def starmap(
self: Seq[tuple[_T1, _T2, _T3, _T4]],
mapping: Callable[[_T1, _T2, _T3, _T4], _TResult],
) -> Seq[_TResult]:
...
) -> Seq[_TResult]: ...

def starmap(self: Seq[Any], mapping: Callable[..., Any]) -> Seq[Any]:
"""Starmap source sequence.
Expand Down Expand Up @@ -227,18 +225,15 @@ def mapi(self, mapping: Callable[[int, _TSource], _TResult]) -> Seq[_TResult]:

@overload
@staticmethod
def range(stop: int) -> Iterable[int]:
...
def range(stop: int) -> Iterable[int]: ...

@overload
@staticmethod
def range(start: int, stop: int) -> Iterable[int]:
...
def range(start: int, stop: int) -> Iterable[int]: ...

@overload
@staticmethod
def range(start: int, stop: int, step: int) -> Iterable[int]:
...
def range(start: int, stop: int, step: int) -> Iterable[int]: ...

@staticmethod
def range(*args: int, **kw: int) -> Iterable[int]:
Expand Down Expand Up @@ -650,22 +645,19 @@ def gen():


@overload
def starmap(mapper: Callable[[_T1, _T2], _TResult]) -> Callable[[Iterable[tuple[_T1, _T2]]], Iterable[_TResult]]:
...
def starmap(mapper: Callable[[_T1, _T2], _TResult]) -> Callable[[Iterable[tuple[_T1, _T2]]], Iterable[_TResult]]: ...


@overload
def starmap(
mapper: Callable[[_T1, _T2, _T3], _TResult],
) -> Callable[[Iterable[tuple[_T1, _T2, _T3]]], Iterable[_TResult]]:
...
) -> Callable[[Iterable[tuple[_T1, _T2, _T3]]], Iterable[_TResult]]: ...


@overload
def starmap(
mapper: Callable[[_T1, _T2, _T3, _T4], _TResult],
) -> Callable[[Iterable[tuple[_T1, _T2, _T3, _T4]]], Iterable[_TResult]]:
...
) -> Callable[[Iterable[tuple[_T1, _T2, _T3, _T4]]], Iterable[_TResult]]: ...


def starmap(mapper: Callable[..., Any]) -> Callable[[Iterable[Any]], Iterable[Any]]:
Expand Down Expand Up @@ -765,21 +757,18 @@ def of_iterable(source: Iterable[_TSource]) -> Seq[_TSource]:


@overload
def range(stop: int) -> Iterable[int]:
...
def range(stop: int) -> Iterable[int]: ...


@overload
def range(
start: int,
stop: int,
) -> Iterable[int]:
...
) -> Iterable[int]: ...


@overload
def range(start: int, stop: int, step: int) -> Iterable[int]:
...
def range(start: int, stop: int, step: int) -> Iterable[int]: ...


def range(*args: int, **kw: int) -> Iterable[int]:
Expand Down
3 changes: 2 additions & 1 deletion expression/core/aiotools.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
Python async / await instead of providing an asynchronous IO mechanism
by itself.
"""

import asyncio
from asyncio import Future, Task
from collections.abc import Awaitable, Callable
Expand Down Expand Up @@ -43,7 +44,7 @@ def from_continuations(callback: Callbacks[_TSource]) -> Awaitable[_TSource]:
An asynchronous computation that provides the callback with the
current continuations.
"""
future: "Future[_TSource]" = asyncio.Future()
future: Future[_TSource] = asyncio.Future()

def done(value: _TSource) -> None:
if not future.done():
Expand Down
Loading
Loading