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

Upgrade pyright and fix typing errors #53

Merged
merged 1 commit into from
May 25, 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
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ repos:
- id: ruff-format
args: [--check]
repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.13
rev: v0.4.5
- hooks:
- id: pyright
name: pyright
entry: pyright
language: node
pass_filenames: false
types: [python]
additional_dependencies: ["[email protected].344"]
additional_dependencies: ["[email protected].364"]
repo: local
11 changes: 6 additions & 5 deletions aioreactive/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
>>> ...

"""

from __future__ import annotations

from collections.abc import AsyncIterable, Awaitable, Callable, Iterable
Expand Down Expand Up @@ -120,13 +121,13 @@ def __getitem__(self, key: slice | int) -> AsyncRx[_TSource]:

return AsyncRx(pipe(self, _slice(start, stop, step or 1)))

@classmethod
def create(cls, source: AsyncObservable[_TSource]) -> AsyncRx[_TSource]:
@staticmethod
def create(source: AsyncObservable[_TResult]) -> AsyncRx[_TResult]:
"""Create `AsyncChainedObservable`.

Helper method for creating an `AsyncChainedObservable`.
"""
return cls(source)
return AsyncRx(source)

@classmethod
def empty(cls) -> AsyncRx[_TSource]:
Expand All @@ -136,8 +137,8 @@ def empty(cls) -> AsyncRx[_TSource]:
def from_iterable(cls, iter: Iterable[_TSource]) -> AsyncRx[_TSource]:
return AsyncRx(from_iterable(iter))

@classmethod
def from_async_iterable(cls, iter: AsyncIterable[_TSource]) -> AsyncObservable[_TSource]:
@staticmethod
def from_async_iterable(iter: AsyncIterable[_TResult]) -> AsyncObservable[_TResult]:
"""Convert an async iterable to an async observable stream.

Example:
Expand Down
2 changes: 1 addition & 1 deletion aioreactive/combine.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ async def update(msg: Msg[_TSource], model: Model[_TSource]) -> Model[_TSource]:
subscriptions=model.subscriptions.add(model.key, inner),
key=Key(model.key + 1),
)
lst = Block.singleton(xs)
lst = Block[AsyncObservable[_TSource]].singleton(xs)
return model.replace(queue=model.queue.append(lst))
case Msg(tag="inner_completed", inner_completed=key):
subscriptions = model.subscriptions.remove(key)
Expand Down
2 changes: 1 addition & 1 deletion aioreactive/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ async def worker() -> None:
try:
task = asyncio.create_task(worker())
except Exception as ex:
log.debug("FromIterable:worker(), Exception: %s" % ex)
log.debug(f"FromIterable:worker(), Exception: {ex}")
await observer.athrow(ex)
else:
tasks.add(task)
Expand Down
1 change: 1 addition & 0 deletions aioreactive/msg.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Internal messages used by mailbox processors. Do not import or use."""

from typing import Generic, Literal, NewType, TypeVar

from expression import case, tag, tagged_union
Expand Down
1 change: 1 addition & 0 deletions aioreactive/testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

Contains utilities for unit testing async observables.
"""

from .observer import AsyncTestObserver
from .subject import AsyncTestSingleSubject, AsyncTestSubject
from .utils import ca
Expand Down
10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ line-length = 120
# D100: Missing docstring in public module
# D104: Missing docstring in public package
# D105: Missing docstring in magic method
ignore = ["D100", "D101", "D102", "D103", "D105", "D107"]
target-version = "py310"
select = ["D", "E", "W", "F", "I", "T", "RUF", "TID", "UP"]
lint.ignore = ["D100", "D101", "D102", "D103", "D105", "D107"]
lint.select = ["D", "E", "W", "F", "I", "T", "RUF", "TID", "UP"]
exclude = ["tests", "docs", "examples"]
target-version = "py310"

[tool.ruff.pydocstyle]
[tool.ruff.lint.pydocstyle]
convention = "google"

[tool.ruff.isort]
[tool.ruff.lint.isort]
lines-after-imports = 2
known-third-party = ["pytest"]

Expand Down
2 changes: 0 additions & 2 deletions tests/test_single_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ def mapper(value: int) -> int:

sink = AsyncTestObserver(asend)
async with await ys.subscribe_async(sink) as sub:

await xs.asend_later(1, 10)

with pytest.raises(ObjectDisposedException):
Expand All @@ -149,7 +148,6 @@ async def mapper(value: int) -> int:

sink: AsyncObserver[int] = AsyncTestObserver()
async with await ys.subscribe_async(sink) as sub:

await xs.asend_later(1, 10)
with pytest.raises(ObjectDisposedException):
await xs.asend_later(1, 20)
Expand Down
1 change: 0 additions & 1 deletion tests/test_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ def mapper(value: int) -> int:

obv: AsyncTestObserver[int] = AsyncTestObserver()
async with await ys.subscribe_async(obv) as subscription:

await xs.asend_later(100, 10)
await xs.asend_later(100, 20)
await xs.asend_later(100, 30)
Expand Down
Loading