From cd386ed4c17ace28234f25bccd31885d62056ae2 Mon Sep 17 00:00:00 2001 From: Vincent Michel Date: Mon, 6 May 2024 11:38:51 +0200 Subject: [PATCH 1/2] Move the setup.cfg configuration to pyproject.toml --- .flake8 | 3 +++ pyproject.toml | 10 ++++++++++ setup.cfg | 9 --------- 3 files changed, 13 insertions(+), 9 deletions(-) create mode 100644 .flake8 delete mode 100644 setup.cfg diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..bc71f97 --- /dev/null +++ b/.flake8 @@ -0,0 +1,3 @@ +[flake8] +max-line-length = 88 +ignore = F401, F403, E731, W503, E501, E203, E704 diff --git a/pyproject.toml b/pyproject.toml index 4f7f664..810109a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,3 +7,13 @@ ignore = ["aiostream/test_utils.py"] [tool.mypy] strict = true packages = ["aiostream", "examples"] + +[tool.black] +line-length = 88 +target_version = ["py38", "py39", "py310", "py311", "py312"] + +[tool.coverage.report] +exclude_also = ["if TYPE_CHECKING:"] + +[tool.ruff] +ignore = ["E501", "F403"] diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 53822cd..0000000 --- a/setup.cfg +++ /dev/null @@ -1,9 +0,0 @@ -[coverage:report] -exclude_lines = - pragma: no cover - if TYPE_CHECKING: - \.\.\. - -[flake8] -max-line-length = 88 -ignore = F401, F403, E731, W503, E501, E203 From 540cdf1d378ec88ce4d5772f189c15bf89f207f9 Mon Sep 17 00:00:00 2001 From: Vincent Michel Date: Mon, 6 May 2024 11:41:00 +0200 Subject: [PATCH 2/2] Bump black and flake8 in pre-commit config --- .pre-commit-config.yaml | 6 +++--- aiostream/aiter_utils.py | 1 + aiostream/core.py | 16 ++++++---------- aiostream/manager.py | 1 + aiostream/pipe.py | 1 + aiostream/stream/advanced.py | 7 ++++--- aiostream/stream/aggregate.py | 1 + aiostream/stream/combine.py | 10 ++++------ aiostream/stream/create.py | 7 +++---- aiostream/stream/misc.py | 1 + aiostream/stream/select.py | 1 + aiostream/stream/time.py | 1 + aiostream/stream/transform.py | 6 ++---- 13 files changed, 29 insertions(+), 30 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4af120d..639d348 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,12 +6,12 @@ repos: - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/ambv/black - rev: 23.3.0 + rev: 24.3.0 hooks: - id: black language_version: python3 - repo: https://github.com/pycqa/flake8 - rev: 5.0.4 + rev: 7.0.0 hooks: - id: flake8 - repo: https://github.com/pre-commit/mirrors-mypy @@ -33,4 +33,4 @@ repos: rev: v0.0.272 hooks: - id: ruff - args: [ --fix, --exit-non-zero-on-fix, --ignore, "E501,F403" ] + args: [ --fix, --exit-non-zero-on-fix] diff --git a/aiostream/aiter_utils.py b/aiostream/aiter_utils.py index df5213d..eb4515e 100644 --- a/aiostream/aiter_utils.py +++ b/aiostream/aiter_utils.py @@ -1,4 +1,5 @@ """Utilities for asynchronous iteration.""" + from __future__ import annotations import sys diff --git a/aiostream/core.py b/aiostream/core.py index 0be5e7d..5de09a5 100644 --- a/aiostream/core.py +++ b/aiostream/core.py @@ -1,4 +1,5 @@ """Core objects for stream operators.""" + from __future__ import annotations import inspect @@ -258,28 +259,23 @@ def streamcontext(aiterable: AsyncIterable[T]) -> Streamer[T]: class OperatorType(Protocol[P, T]): - def __call__(self, *args: P.args, **kwargs: P.kwargs) -> Stream[T]: - ... + def __call__(self, *args: P.args, **kwargs: P.kwargs) -> Stream[T]: ... - def raw(self, *args: P.args, **kwargs: P.kwargs) -> AsyncIterator[T]: - ... + def raw(self, *args: P.args, **kwargs: P.kwargs) -> AsyncIterator[T]: ... class PipableOperatorType(Protocol[A, P, T]): def __call__( self, source: AsyncIterable[A], /, *args: P.args, **kwargs: P.kwargs - ) -> Stream[T]: - ... + ) -> Stream[T]: ... def raw( self, source: AsyncIterable[A], /, *args: P.args, **kwargs: P.kwargs - ) -> AsyncIterator[T]: - ... + ) -> AsyncIterator[T]: ... def pipe( self, *args: P.args, **kwargs: P.kwargs - ) -> Callable[[AsyncIterable[A]], Stream[T]]: - ... + ) -> Callable[[AsyncIterable[A]], Stream[T]]: ... # Operator decorator diff --git a/aiostream/manager.py b/aiostream/manager.py index bab224a..be52d52 100644 --- a/aiostream/manager.py +++ b/aiostream/manager.py @@ -1,6 +1,7 @@ """Provide a context to easily manage several streamers running concurrently. """ + from __future__ import annotations import asyncio diff --git a/aiostream/pipe.py b/aiostream/pipe.py index c27e101..ec872a6 100644 --- a/aiostream/pipe.py +++ b/aiostream/pipe.py @@ -1,4 +1,5 @@ """Gather the pipe operators.""" + from __future__ import annotations from . import stream diff --git a/aiostream/stream/advanced.py b/aiostream/stream/advanced.py index 106f0f1..447da7d 100644 --- a/aiostream/stream/advanced.py +++ b/aiostream/stream/advanced.py @@ -1,4 +1,5 @@ """Advanced operators (to deal with streams of higher order) .""" + from __future__ import annotations from typing import AsyncIterator, AsyncIterable, TypeVar, Union, cast @@ -46,9 +47,9 @@ async def base_combine( # Safe context async with StreamerManager[Union[AsyncIterable[T], T]]() as manager: - main_streamer: Streamer[ - AsyncIterable[T] | T - ] | None = await manager.enter_and_create_task(source) + main_streamer: Streamer[AsyncIterable[T] | T] | None = ( + await manager.enter_and_create_task(source) + ) # Loop over events while manager.tasks: diff --git a/aiostream/stream/aggregate.py b/aiostream/stream/aggregate.py index 8ed7c0e..0d3e604 100644 --- a/aiostream/stream/aggregate.py +++ b/aiostream/stream/aggregate.py @@ -1,4 +1,5 @@ """Aggregation operators.""" + from __future__ import annotations import asyncio diff --git a/aiostream/stream/combine.py b/aiostream/stream/combine.py index a782a73..b3534c2 100644 --- a/aiostream/stream/combine.py +++ b/aiostream/stream/combine.py @@ -1,4 +1,5 @@ """Combination operators.""" + from __future__ import annotations import asyncio @@ -93,18 +94,15 @@ async def zip( class SmapCallable(Protocol[X, Y]): - def __call__(self, arg: X, /, *args: X) -> Y: - ... + def __call__(self, arg: X, /, *args: X) -> Y: ... class AmapCallable(Protocol[X, Y]): - async def __call__(self, arg: X, /, *args: X) -> Y: - ... + async def __call__(self, arg: X, /, *args: X) -> Y: ... class MapCallable(Protocol[X, Y]): - def __call__(self, arg: X, /, *args: X) -> Awaitable[Y] | Y: - ... + def __call__(self, arg: X, /, *args: X) -> Awaitable[Y] | Y: ... @pipable_operator diff --git a/aiostream/stream/create.py b/aiostream/stream/create.py index 8037fcb..cded68c 100644 --- a/aiostream/stream/create.py +++ b/aiostream/stream/create.py @@ -1,4 +1,5 @@ """Non-pipable creation operators.""" + from __future__ import annotations import sys @@ -96,13 +97,11 @@ async def just(value: T) -> AsyncIterator[T]: class SyncCallable(Protocol[P, Y]): - def __call__(self, *args: P.args, **kwargs: P.kwargs) -> Y: - ... + def __call__(self, *args: P.args, **kwargs: P.kwargs) -> Y: ... class AsyncCallable(Protocol[P, Y]): - def __call__(self, *args: P.args, **kwargs: P.kwargs) -> Awaitable[Y]: - ... + def __call__(self, *args: P.args, **kwargs: P.kwargs) -> Awaitable[Y]: ... @operator diff --git a/aiostream/stream/misc.py b/aiostream/stream/misc.py index 1be834e..ebf595e 100644 --- a/aiostream/stream/misc.py +++ b/aiostream/stream/misc.py @@ -1,4 +1,5 @@ """Extra operators.""" + from __future__ import annotations import asyncio diff --git a/aiostream/stream/select.py b/aiostream/stream/select.py index ecc8ba3..6acac44 100644 --- a/aiostream/stream/select.py +++ b/aiostream/stream/select.py @@ -1,4 +1,5 @@ """Selection operators.""" + from __future__ import annotations import asyncio diff --git a/aiostream/stream/time.py b/aiostream/stream/time.py index c9c0df8..a1b6def 100644 --- a/aiostream/stream/time.py +++ b/aiostream/stream/time.py @@ -1,4 +1,5 @@ """Time-specific operators.""" + from __future__ import annotations import asyncio diff --git a/aiostream/stream/transform.py b/aiostream/stream/transform.py index f11bffa..a071916 100644 --- a/aiostream/stream/transform.py +++ b/aiostream/stream/transform.py @@ -49,13 +49,11 @@ async def enumerate( class AsyncStarmapCallable(Protocol[X, Y]): - def __call__(self, arg: X, /, *args: X) -> Awaitable[Y]: - ... + def __call__(self, arg: X, /, *args: X) -> Awaitable[Y]: ... class SyncStarmapCallable(Protocol[X, Y]): - def __call__(self, arg: X, /, *args: X) -> Y: - ... + def __call__(self, arg: X, /, *args: X) -> Y: ... @pipable_operator