Skip to content

Commit

Permalink
Low-level API: Moved easynetwork.lowlevel._asyncio in easynetwork.low…
Browse files Browse the repository at this point in the history
…level.api_async.backend
  • Loading branch information
francis-clairicia committed Jun 28, 2024
1 parent deb074a commit 769a68f
Show file tree
Hide file tree
Showing 36 changed files with 109 additions and 101 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from collections.abc import Iterable, Sequence
from typing import Any, cast

from .. import _utils
from .... import _utils


async def ensure_resolved(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import types
from collections.abc import Callable

from .. import _utils
from .... import _utils
from .tasks import TaskUtils


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
from collections.abc import Awaitable, Callable, Coroutine, Mapping, Sequence
from typing import Any, NoReturn, ParamSpec, TypeVar, TypeVarTuple

from .. import _utils
from ..api_async.backend import _sniffio_helpers
from ..api_async.backend.abc import AsyncBackend as AbstractAsyncBackend, ILock, TaskInfo
from ..constants import HAPPY_EYEBALLS_DELAY as _DEFAULT_HAPPY_EYEBALLS_DELAY
from .... import _utils
from ....constants import HAPPY_EYEBALLS_DELAY as _DEFAULT_HAPPY_EYEBALLS_DELAY
from .. import _sniffio_helpers
from ..abc import AsyncBackend as AbstractAsyncBackend, ILock, TaskInfo
from ._asyncio_utils import (
create_connection,
create_datagram_connection,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import warnings
from typing import Any, final

from ... import _utils
from ..... import _utils
from .._flow_control import WriteFlowControl


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
from collections.abc import Callable, Coroutine, Mapping
from typing import Any, NoReturn, final

from ... import _utils, socket as socket_tools
from ...api_async.backend.abc import AsyncBackend, TaskGroup
from ...api_async.transports import abc as transports
from ..... import _utils, socket as socket_tools
from ....transports import abc as transports
from ...abc import AsyncBackend, TaskGroup
from .._flow_control import WriteFlowControl
from .endpoint import _monkeypatch_transport

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
from collections.abc import Callable, Mapping
from typing import Any, final

from ... import _utils, socket as socket_tools
from ...api_async.backend.abc import AsyncBackend
from ...api_async.transports.abc import AsyncDatagramTransport
from ..... import _utils, socket as socket_tools
from ....transports.abc import AsyncDatagramTransport
from ...abc import AsyncBackend
from .endpoint import DatagramEndpoint


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
from collections.abc import Callable, Coroutine, Mapping
from typing import Any, Generic, NoReturn, TypeVar, final

from ... import _utils, constants, socket as socket_tools
from ...api_async.backend.abc import AsyncBackend, CancelScope, TaskGroup
from ...api_async.transports.abc import AsyncListener, AsyncStreamTransport
from ..... import _utils, constants, socket as socket_tools
from ....transports.abc import AsyncListener, AsyncStreamTransport
from ...abc import AsyncBackend, CancelScope, TaskGroup
from ..tasks import TaskUtils
from .socket import AsyncioTransportStreamSocketAdapter, StreamReaderBufferedProtocol

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
from types import TracebackType
from typing import TYPE_CHECKING, Any, final

from ....exceptions import UnsupportedOperation
from ... import _utils, socket as socket_tools
from ...api_async.backend.abc import AsyncBackend
from ...api_async.transports.abc import AsyncStreamTransport
from ......exceptions import UnsupportedOperation
from ..... import _utils, socket as socket_tools
from ....transports.abc import AsyncStreamTransport
from ...abc import AsyncBackend
from .._asyncio_utils import add_flowcontrol_defaults
from .._flow_control import WriteFlowControl

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,9 @@
from typing import Any, ClassVar, NamedTuple, Self, TypeVar, TypeVarTuple, cast, final
from weakref import WeakKeyDictionary

from .. import _utils
from .._final import runtime_final_class
from ..api_async.backend.abc import (
CancelScope as AbstractCancelScope,
Task as AbstractTask,
TaskGroup as AbstractTaskGroup,
TaskInfo,
)
from .... import _utils
from ...._final import runtime_final_class
from ..abc import CancelScope as AbstractCancelScope, Task as AbstractTask, TaskGroup as AbstractTaskGroup, TaskInfo

_T = TypeVar("_T")
_T_co = TypeVar("_T_co", covariant=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
from types import TracebackType
from typing import ParamSpec, Self, TypeVar, final

from .. import _lock, _utils
from .._final import runtime_final_class
from ..api_async.backend import _sniffio_helpers
from ..api_async.backend.abc import ThreadsPortal as AbstractThreadsPortal
from .... import _lock, _utils
from ...._final import runtime_final_class
from .. import _sniffio_helpers
from ..abc import ThreadsPortal as AbstractThreadsPortal
from .tasks import TaskUtils

_P = ParamSpec("_P")
Expand Down
2 changes: 1 addition & 1 deletion src/easynetwork/lowlevel/api_async/backend/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def ensure_backend(backend: AsyncBackend | BuiltinAsyncBackendLiteral | None) ->

match backend:
case "asyncio":
from ..._asyncio.backend import AsyncIOBackend
from ._asyncio.backend import AsyncIOBackend

return AsyncIOBackend()
case AsyncBackend():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from contextlib import ExitStack
from typing import TYPE_CHECKING, Any, Literal, Required, TypedDict

from easynetwork.lowlevel._asyncio.backend import AsyncIOBackend
from easynetwork.lowlevel.api_async.backend._asyncio.backend import AsyncIOBackend
from easynetwork.lowlevel.api_async.backend.abc import TaskInfo

import pytest
Expand Down Expand Up @@ -1226,7 +1226,7 @@ def cancel_shielded_coroutine(
case "run_in_thread":
return lambda: backend.run_in_thread(time.sleep, 0.1)
case "cancel_shielded_wait_asyncio_futures":
from easynetwork.lowlevel._asyncio.tasks import TaskUtils
from easynetwork.lowlevel.api_async.backend._asyncio.tasks import TaskUtils

async def cancel_shielded_wait_asyncio_futures() -> None:
loop = asyncio.get_running_loop()
Expand Down
2 changes: 1 addition & 1 deletion tests/functional_test/test_async/test_futures.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from collections.abc import AsyncIterator
from typing import Any

from easynetwork.lowlevel._asyncio.backend import AsyncIOBackend
from easynetwork.lowlevel.api_async.backend._asyncio.backend import AsyncIOBackend
from easynetwork.lowlevel.futures import AsyncExecutor, unwrap_future

import pytest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from easynetwork.clients.async_udp import AsyncUDPNetworkClient
from easynetwork.exceptions import ClientClosedError, DatagramProtocolParseError
from easynetwork.lowlevel._asyncio.datagram.endpoint import DatagramEndpoint, create_datagram_endpoint
from easynetwork.lowlevel.api_async.backend._asyncio.datagram.endpoint import DatagramEndpoint, create_datagram_endpoint
from easynetwork.lowlevel.socket import IPv4SocketAddress, IPv6SocketAddress, SocketProxy
from easynetwork.protocol import DatagramProtocol

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
IncrementalDeserializeError,
StreamProtocolParseError,
)
from easynetwork.lowlevel._asyncio._asyncio_utils import create_connection
from easynetwork.lowlevel._asyncio.backend import AsyncIOBackend
from easynetwork.lowlevel._asyncio.stream.listener import ListenerSocketAdapter
from easynetwork.lowlevel.api_async.backend._asyncio._asyncio_utils import create_connection
from easynetwork.lowlevel.api_async.backend._asyncio.backend import AsyncIOBackend
from easynetwork.lowlevel.api_async.backend._asyncio.stream.listener import ListenerSocketAdapter
from easynetwork.lowlevel.api_async.backend.abc import AsyncBackend
from easynetwork.lowlevel.socket import SocketAddress, enable_socket_linger
from easynetwork.protocol import AnyStreamProtocolType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
from typing import Any

from easynetwork.exceptions import BaseProtocolParseError, ClientClosedError, DatagramProtocolParseError, DeserializeError
from easynetwork.lowlevel._asyncio.backend import AsyncIOBackend
from easynetwork.lowlevel._asyncio.datagram.endpoint import DatagramEndpoint, create_datagram_endpoint
from easynetwork.lowlevel._asyncio.datagram.listener import DatagramListenerSocketAdapter
from easynetwork.lowlevel.api_async.backend._asyncio.backend import AsyncIOBackend
from easynetwork.lowlevel.api_async.backend._asyncio.datagram.endpoint import DatagramEndpoint, create_datagram_endpoint
from easynetwork.lowlevel.api_async.backend._asyncio.datagram.listener import DatagramListenerSocketAdapter
from easynetwork.lowlevel.socket import SocketAddress
from easynetwork.protocol import DatagramProtocol
from easynetwork.servers.async_udp import AsyncUDPNetworkServer
Expand Down
4 changes: 2 additions & 2 deletions tests/unit_test/test_async/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from collections.abc import Callable, Iterable
from typing import TYPE_CHECKING

from easynetwork.lowlevel._asyncio.backend import AsyncIOBackend
from easynetwork.lowlevel.api_async.backend._asyncio.backend import AsyncIOBackend
from easynetwork.lowlevel.api_async.backend.abc import AsyncBackend
from easynetwork.lowlevel.api_async.transports.abc import AsyncDatagramTransport, AsyncStreamTransport

Expand Down Expand Up @@ -51,7 +51,7 @@ def fake_cancellation_cls() -> type[BaseException]:

@pytest.fixture
def mock_backend(fake_cancellation_cls: type[BaseException], mocker: MockerFixture) -> MagicMock:
from easynetwork.lowlevel._asyncio.tasks import CancelScope, TaskGroup
from easynetwork.lowlevel.api_async.backend._asyncio.tasks import CancelScope, TaskGroup

from .._utils import AsyncDummyLock

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from collections.abc import Callable
from typing import TYPE_CHECKING

from easynetwork.lowlevel._asyncio.datagram.endpoint import DatagramEndpoint
from easynetwork.lowlevel.api_async.backend._asyncio.datagram.endpoint import DatagramEndpoint

import pytest

Expand Down
Loading

0 comments on commit 769a68f

Please sign in to comment.