Skip to content

Commit

Permalink
fix: ruff, pyright 38 -> 39
Browse files Browse the repository at this point in the history
  • Loading branch information
phi-friday committed Jul 30, 2024
1 parent fc19025 commit c3e5b4e
Show file tree
Hide file tree
Showing 13 changed files with 41 additions and 35 deletions.
2 changes: 1 addition & 1 deletion pyrightconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"tests"
],
"typeCheckingMode": "strict",
"pythonVersion": "3.8",
"pythonVersion": "3.9",
"pythonPlatform": "Linux",
"reportMissingTypeStubs": false,
"reportInconsistentConstructor": false,
Expand Down
2 changes: 1 addition & 1 deletion ruff.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
line-length = 88
unsafe-fixes = true
target-version = "py38"
target-version = "py39"

[lint]
select = ["ALL"]
Expand Down
5 changes: 4 additions & 1 deletion src/async_wrapper/convert/_async.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
from __future__ import annotations

from functools import partial, wraps
from typing import Any, Callable, Coroutine
from typing import TYPE_CHECKING, Any, Callable

from anyio import to_thread
from typing_extensions import ParamSpec, TypeVar

if TYPE_CHECKING:
from collections.abc import Coroutine

ValueT = TypeVar("ValueT", infer_variance=True)
ParamT = ParamSpec("ParamT")

Expand Down
5 changes: 4 additions & 1 deletion src/async_wrapper/convert/_sync/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@
from contextvars import ContextVar
from functools import partial, wraps
from importlib.util import find_spec
from typing import Any, Awaitable, Callable, Coroutine, overload
from typing import TYPE_CHECKING, Any, Callable, overload

import anyio
from sniffio import AsyncLibraryNotFoundError, current_async_library
from typing_extensions import ParamSpec, TypeAlias, TypeVar

from async_wrapper.convert._sync.sqlalchemy import check_is_unset, run_sa_greenlet

if TYPE_CHECKING:
from collections.abc import Awaitable, Coroutine

ValueT = TypeVar("ValueT", infer_variance=True)
ParamT = ParamSpec("ParamT")
AnyAwaitable: TypeAlias = "Awaitable[ValueT] | Coroutine[Any, Any, ValueT]"
Expand Down
4 changes: 3 additions & 1 deletion src/async_wrapper/convert/_sync/sqlalchemy.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from __future__ import annotations

from contextlib import suppress
from typing import TYPE_CHECKING, Any, Awaitable, Coroutine
from typing import TYPE_CHECKING, Any

from typing_extensions import TypeAlias, TypeGuard, TypeVar

if TYPE_CHECKING:
from collections.abc import Awaitable, Coroutine

import greenlet


Expand Down
5 changes: 4 additions & 1 deletion src/async_wrapper/convert/main.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
from __future__ import annotations

from inspect import iscoroutinefunction
from typing import Any, Callable, Coroutine, overload
from typing import TYPE_CHECKING, Any, Callable, overload

from typing_extensions import ParamSpec, TypeVar

from async_wrapper.convert._async import sync_to_async
from async_wrapper.convert._sync import async_to_sync

if TYPE_CHECKING:
from collections.abc import Coroutine

ValueT = TypeVar("ValueT", infer_variance=True)
ParamT = ParamSpec("ParamT")

Expand Down
12 changes: 3 additions & 9 deletions src/async_wrapper/pipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,16 @@
import threading
from collections import deque
from contextlib import AsyncExitStack, suppress
from typing import (
TYPE_CHECKING,
Any,
Awaitable,
Callable,
Generic,
Protocol,
runtime_checkable,
)
from typing import TYPE_CHECKING, Any, Callable, Generic, Protocol, runtime_checkable

import anyio
from typing_extensions import TypedDict, TypeVar, override

from async_wrapper.exception import AlreadyDisposedError

if TYPE_CHECKING:
from collections.abc import Awaitable

from anyio.abc import CapacityLimiter, Lock, Semaphore

class Synchronization(TypedDict, total=False):
Expand Down
26 changes: 11 additions & 15 deletions src/async_wrapper/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,13 @@

import math
import sys
from contextlib import asynccontextmanager, contextmanager
from typing import (
TYPE_CHECKING,
Any,
AsyncContextManager,
AsyncGenerator,
ContextManager,
Generator,
Generic,
Literal,
NoReturn,
from contextlib import (
AbstractAsyncContextManager,
AbstractContextManager,
asynccontextmanager,
contextmanager,
)
from typing import TYPE_CHECKING, Any, Generic, Literal, NoReturn

from anyio import WouldBlock, create_memory_object_stream, create_task_group, fail_after
from anyio.streams.memory import BrokenResourceError, ClosedResourceError, EndOfStream
Expand All @@ -31,6 +26,7 @@
from exceptiongroup import ExceptionGroup

if TYPE_CHECKING:
from collections.abc import AsyncGenerator, Generator
from types import TracebackType

from anyio.streams.memory import (
Expand Down Expand Up @@ -131,22 +127,22 @@ def _init(
self._close_getter: bool = True

@property
def aputter(self) -> AsyncContextManager[Self]:
def aputter(self) -> AbstractAsyncContextManager[Self]:
"""aclose putter only"""
return self._as_aputter()

@property
def agetter(self) -> AsyncContextManager[Self]:
def agetter(self) -> AbstractAsyncContextManager[Self]:
"""aclose getter only"""
return self._as_agetter()

@property
def putter(self) -> ContextManager[Self]:
def putter(self) -> AbstractContextManager[Self]:
"""close putter only"""
return self._as_putter()

@property
def getter(self) -> ContextManager[Self]:
def getter(self) -> AbstractContextManager[Self]:
"""close getter only"""
return self._as_getter()

Expand Down
3 changes: 2 additions & 1 deletion src/async_wrapper/task_group/task_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from contextlib import AsyncExitStack
from functools import partial, wraps
from typing import TYPE_CHECKING, Any, Awaitable, Callable, Coroutine, Generic
from typing import TYPE_CHECKING, Any, Callable, Generic

from anyio import create_task_group as _create_task_group
from anyio.abc import TaskGroup as _TaskGroup
Expand All @@ -11,6 +11,7 @@
from async_wrapper.task_group.value import SoonValue

if TYPE_CHECKING:
from collections.abc import Awaitable, Coroutine
from types import TracebackType

from anyio.abc import CancelScope, CapacityLimiter, Lock, Semaphore
Expand Down
3 changes: 2 additions & 1 deletion src/async_wrapper/wait.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
from __future__ import annotations

from functools import partial
from typing import TYPE_CHECKING, Any, Awaitable, Callable, Iterable
from typing import TYPE_CHECKING, Any, Callable

from anyio import EndOfStream, Event, create_memory_object_stream, create_task_group
from typing_extensions import ParamSpec, Self, TypeVar, override

from async_wrapper.exception import PendingError

if TYPE_CHECKING:
from collections.abc import Awaitable, Iterable
from types import TracebackType

from anyio import EventStatistics
Expand Down
3 changes: 2 additions & 1 deletion tests/convert/test_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

import inspect
import time
from collections.abc import AsyncGenerator, Generator
from pathlib import Path
from tempfile import TemporaryDirectory
from typing import Any, AsyncGenerator, Generator
from typing import Any

import anyio
import pytest
Expand Down
3 changes: 2 additions & 1 deletion tests/convert/test_sync.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from __future__ import annotations

import inspect
from typing import Any, Coroutine, Generator, Generic
from collections.abc import Coroutine, Generator
from typing import Any, Generic

import anyio
import pytest
Expand Down
3 changes: 2 additions & 1 deletion tests/test_pipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

import inspect
from collections import deque
from collections.abc import Awaitable
from contextlib import suppress
from functools import partial
from typing import Any, Awaitable, Callable
from typing import Any, Callable

import anyio
import pytest
Expand Down

0 comments on commit c3e5b4e

Please sign in to comment.