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

Updated pdm, dev dependencies, and pre-commit pinned versions #338

Merged
merged 1 commit into from
Aug 3, 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 .github/actions/setup-tox/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ runs:
shell: bash
- uses: pdm-project/setup-pdm@v4
with:
version: '2.16.1'
version: '2.17.3'
python-version: ${{ inputs.python-version }}
### setup-pdm cache seems broken. See https://github.com/pdm-project/setup-pdm/issues/43
# cache: true
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ci:

repos:
- repo: https://github.com/asottile/pyupgrade
rev: v3.16.0
rev: v3.17.0
hooks:
- id: pyupgrade
args: ['--py311-plus']
Expand All @@ -22,7 +22,7 @@ repos:
- id: isort
args: ['--filter-files', '--settings-file', 'pyproject.toml']
- repo: https://github.com/psf/black
rev: '24.4.2'
rev: '24.8.0'
hooks:
- id: black
args: ['--config', 'pyproject.toml']
Expand All @@ -46,7 +46,7 @@ repos:
types: [] # Overwrite with empty in order to fallback to types_or
types_or: [python, pyi]
- repo: https://github.com/pdm-project/pdm
rev: '2.16.1'
rev: '2.17.3'
hooks:
- id: pdm-lock-check
- id: pdm-export
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build:
python: "3.11"
jobs:
post_create_environment:
- pip install --no-cache-dir pdm==2.16.1
- pip install --no-cache-dir pdm==2.17.3
- pdm config check_update false
- pdm use -f $READTHEDOCS_VIRTUALENV_PATH
post_install:
Expand Down
2 changes: 1 addition & 1 deletion benchmark_server/servers/easynetwork_tcp_echoserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
class NoSerializer(BufferedIncrementalPacketSerializer[bytes, bytes, memoryview]):
__slots__ = ()

def incremental_serialize(self, packet: bytes) -> Generator[bytes, None, None]:
def incremental_serialize(self, packet: bytes) -> Generator[bytes]:
yield packet

def incremental_deserialize(self) -> Generator[None, bytes, tuple[bytes, bytes]]:
Expand Down
2 changes: 1 addition & 1 deletion benchmark_server/servers/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Please do not edit it manually.

asyncio-dgram==2.1.2
attrs==23.2.0
attrs==24.1.0
cffi==1.16.0
idna==3.7
outcome==1.3.0.post0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def deserialize(self, data: bytes) -> ReceivedPacket:
except (UnicodeError, json.JSONDecodeError) as exc:
raise DeserializeError("JSON decode error") from exc

def incremental_serialize(self, packet: SentPacket) -> Generator[bytes, None, None]:
def incremental_serialize(self, packet: SentPacket) -> Generator[bytes]:
yield self._dump(packet) + b"\r\n"

def incremental_deserialize(self) -> Generator[None, bytes, tuple[ReceivedPacket, bytes]]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def deserialize(self, data: bytes) -> ReceivedPacket:
except (UnicodeError, json.JSONDecodeError) as exc:
raise DeserializeError("JSON decode error") from exc

def incremental_serialize(self, packet: SentPacket) -> Generator[bytes, None, None]:
def incremental_serialize(self, packet: SentPacket) -> Generator[bytes]:
yield self._dump(packet) + b"\r\n"

def incremental_deserialize(self) -> Generator[None, bytes, tuple[ReceivedPacket, bytes]]:
Expand Down
270 changes: 148 additions & 122 deletions pdm.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ format = [
"black>=22.6.0",
]
mypy = [
"mypy~=1.10",
"mypy~=1.11",
]
types-msgpack = [
"msgpack-types>=0.2.0",
Expand Down
2 changes: 1 addition & 1 deletion src/easynetwork/lowlevel/_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __init__(self, protocol: AnyStreamProtocolType[_T_SentPacket, Any]) -> None:
_check_any_protocol(protocol)
self.__protocol: AnyStreamProtocolType[_T_SentPacket, Any] = protocol

def generate(self, packet: _T_SentPacket) -> Generator[bytes, None, None]:
def generate(self, packet: _T_SentPacket) -> Generator[bytes]:
try:
yield from self.__protocol.generate_chunks(packet)
except Exception as exc:
Expand Down
4 changes: 2 additions & 2 deletions src/easynetwork/lowlevel/api_async/backend/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ def open_cancel_scope(self, *, deadline: float = ...) -> CancelScope:
"""
raise NotImplementedError

def timeout(self, delay: float) -> AbstractContextManager[CancelScope]:
def timeout(self, delay: float) -> AbstractContextManager[CancelScope, None]:
"""
Returns a :term:`context manager` that can be used to limit the amount of time spent waiting on something.

Expand All @@ -741,7 +741,7 @@ def timeout(self, delay: float) -> AbstractContextManager[CancelScope]:
"""
return _timeout_scope(self.move_on_after(delay))

def timeout_at(self, deadline: float) -> AbstractContextManager[CancelScope]:
def timeout_at(self, deadline: float) -> AbstractContextManager[CancelScope, None]:
"""
Returns a :term:`context manager` that can be used to limit the amount of time spent waiting on something.

Expand Down
4 changes: 2 additions & 2 deletions src/easynetwork/lowlevel/futures.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ async def run(self, func: Callable[_P, _T], /, *args: _P.args, **kwargs: _P.kwar
backend = self.__backend
return await _result_or_cancel(executor.submit(func, *args, **kwargs), backend)

def map(self, func: Callable[..., _T], *iterables: Iterable[Any]) -> AsyncGenerator[_T, None]:
def map(self, func: Callable[..., _T], *iterables: Iterable[Any]) -> AsyncGenerator[_T]:
"""
Returns an asynchronous iterator equivalent to ``map(fn, iter)``.

Expand All @@ -160,7 +160,7 @@ def pow_50(x):
backend = self.__backend
fs = deque(executor.submit(self._setup_func(func), *args) for args in zip(*iterables))

async def result_iterator() -> AsyncGenerator[_T, None]:
async def result_iterator() -> AsyncGenerator[_T]:
try:
while fs:
yield await _result_or_cancel(fs.popleft(), backend)
Expand Down
4 changes: 2 additions & 2 deletions src/easynetwork/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def create_buffer(self, sizehint: int) -> _T_Buffer:
"""
return self.__serializer.create_deserializer_buffer(sizehint)

def generate_chunks(self, packet: _T_SentPacket) -> Generator[bytes, None, None]:
def generate_chunks(self, packet: _T_SentPacket) -> Generator[bytes]:
"""
Serializes a Python object to a raw :term:`packet` part by part.

Expand Down Expand Up @@ -256,7 +256,7 @@ def __init__(
self.__serializer: AbstractIncrementalPacketSerializer[Any, Any] = serializer
self.__converter: AbstractPacketConverterComposite[_T_SentPacket, _T_ReceivedPacket, Any, Any] | None = converter

def generate_chunks(self, packet: _T_SentPacket) -> Generator[bytes, None, None]:
def generate_chunks(self, packet: _T_SentPacket) -> Generator[bytes]:
"""
Serializes a Python object to a raw :term:`packet` part by part.

Expand Down
2 changes: 1 addition & 1 deletion src/easynetwork/serializers/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class AbstractIncrementalPacketSerializer(AbstractPacketSerializer[_T_SentDTOPac
__slots__ = ()

@abstractmethod
def incremental_serialize(self, packet: _T_SentDTOPacket, /) -> Generator[bytes, None, None]:
def incremental_serialize(self, packet: _T_SentDTOPacket, /) -> Generator[bytes]:
"""
Returns the byte representation of the Python object `packet`.

Expand Down
6 changes: 3 additions & 3 deletions src/easynetwork/serializers/base_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def serialize(self, packet: _T_SentDTOPacket, /) -> bytes:
raise NotImplementedError

@final
def incremental_serialize(self, packet: _T_SentDTOPacket, /) -> Generator[bytes, None, None]:
def incremental_serialize(self, packet: _T_SentDTOPacket, /) -> Generator[bytes]:
"""
Yields the data returned by :meth:`serialize` and appends `separator`.

Expand Down Expand Up @@ -246,7 +246,7 @@ def serialize(self, packet: _T_SentDTOPacket, /) -> bytes:
raise NotImplementedError

@final
def incremental_serialize(self, packet: _T_SentDTOPacket, /) -> Generator[bytes, None, None]:
def incremental_serialize(self, packet: _T_SentDTOPacket, /) -> Generator[bytes]:
"""
Yields the data returned by :meth:`serialize`.

Expand Down Expand Up @@ -462,7 +462,7 @@ def deserialize(self, data: bytes, /) -> _T_ReceivedDTOPacket:
return packet

@final
def incremental_serialize(self, packet: _T_SentDTOPacket, /) -> Generator[bytes, None, None]:
def incremental_serialize(self, packet: _T_SentDTOPacket, /) -> Generator[bytes]:
"""
Calls :meth:`dump_to_file` and yields the result.

Expand Down
2 changes: 1 addition & 1 deletion src/easynetwork/serializers/composite.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def sent_packet_serializer(self) -> AbstractIncrementalPacketSerializer[_T_SentD
@property
def received_packet_serializer(self) -> AbstractIncrementalPacketSerializer[Any, _T_ReceivedDTOPacket]: ...

def incremental_serialize(self, packet: _T_SentDTOPacket) -> Generator[bytes, None, None]:
def incremental_serialize(self, packet: _T_SentDTOPacket) -> Generator[bytes]:
"""
Calls ``self.sent_packet_serializer.incremental_serialize(packet)``.

Expand Down
2 changes: 1 addition & 1 deletion src/easynetwork/serializers/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def serialize(self, packet):
return self.__encoder.encode(packet).encode(self.__encoding, self.__unicode_errors)

@final
def incremental_serialize(self, packet: Any) -> Generator[bytes, None, None]:
def incremental_serialize(self, packet: Any) -> Generator[bytes]:
r"""
Returns the JSON representation of the Python object `packet`.

Expand Down
2 changes: 1 addition & 1 deletion src/easynetwork/serializers/line.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def serialize(self, packet):
return packet.encode(self.__encoding, self.__unicode_errors)

@final
def incremental_serialize(self, packet: str) -> Generator[bytes, None, None]:
def incremental_serialize(self, packet: str) -> Generator[bytes]:
"""
Encodes the given string to bytes and appends `separator`.

Expand Down
2 changes: 1 addition & 1 deletion src/easynetwork/serializers/wrapper/compressor.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def serialize(self, packet: _T_SentDTOPacket) -> bytes:
return compressor.compress(self.__serializer.serialize(packet)) + compressor.flush()

@final
def incremental_serialize(self, packet: _T_SentDTOPacket) -> Generator[bytes, None, None]:
def incremental_serialize(self, packet: _T_SentDTOPacket) -> Generator[bytes]:
"""
Serializes `packet` and yields the compressed data parts.

Expand Down
4 changes: 2 additions & 2 deletions tests/functional_test/test_communication/serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def serialize(self, packet: str) -> bytes:
raise TypeError("is not a string")
return packet.encode(encoding=self.encoding)

def incremental_serialize(self, packet: str) -> Generator[bytes, None, None]:
def incremental_serialize(self, packet: str) -> Generator[bytes]:
if not isinstance(packet, str):
raise TypeError("is not a string")
if "\n" in packet:
Expand Down Expand Up @@ -99,6 +99,6 @@ class BadSerializeStringSerializer(StringSerializer):
def serialize(self, packet: str) -> bytes:
raise SystemError("CRASH")

def incremental_serialize(self, packet: str) -> Generator[bytes, None, None]:
def incremental_serialize(self, packet: str) -> Generator[bytes]:
raise SystemError("CRASH")
yield b"chunk" # type: ignore[unreachable]
4 changes: 2 additions & 2 deletions tests/unit_test/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def mock_buffered_stream_protocol(
mock_buffered_stream_protocol: MagicMock,
mocker: MockerFixture,
) -> MagicMock:
def generate_chunks_side_effect(packet: Any) -> Generator[bytes, None, None]:
def generate_chunks_side_effect(packet: Any) -> Generator[bytes]:
yield str(packet).removeprefix("sentinel.").encode("ascii") + b"\n"

def build_packet_from_buffer_side_effect(buffer: memoryview) -> Generator[None, int, tuple[Any, bytes]]:
Expand Down Expand Up @@ -142,7 +142,7 @@ def mock_stream_protocol(
mock_buffered_stream_protocol: MagicMock,
mocker: MockerFixture,
) -> MagicMock:
def generate_chunks_side_effect(packet: Any) -> Generator[bytes, None, None]:
def generate_chunks_side_effect(packet: Any) -> Generator[bytes]:
yield str(packet).removeprefix("sentinel.").encode("ascii") + b"\n"

def build_packet_from_chunks_side_effect() -> Generator[None, bytes, tuple[Any, bytes]]:
Expand Down
4 changes: 2 additions & 2 deletions tests/unit_test/test_async/test_api/test_server/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ async def test____build_lowlevel_datagram_server_handler____skip_initialization(
# Arrange

@contextlib.asynccontextmanager
async def initializer(client: Any) -> AsyncGenerator[None, None]:
async def initializer(client: Any) -> AsyncGenerator[None]:
yield

ctx = mocker.sentinel.ctx
Expand All @@ -60,7 +60,7 @@ async def test____build_lowlevel_stream_server_handler____skip_initialization(mo
# Arrange

@contextlib.asynccontextmanager
async def initializer(client: Any) -> AsyncGenerator[None, None]:
async def initializer(client: Any) -> AsyncGenerator[None]:
yield

ctx = mocker.sentinel.ctx
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ async def test____send_packet____protocol_crashed(
mock_stream_transport.send_all_from_iterable.side_effect = lambda it: chunks.extend(it)
expected_error = Exception("Error")

def side_effect(packet: Any) -> Generator[bytes, None, None]:
def side_effect(packet: Any) -> Generator[bytes]:
raise expected_error
yield # type: ignore[unreachable]

Expand Down
4 changes: 2 additions & 2 deletions tests/unit_test/test_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ class _BaseTestAnyStreamProtocol:
sentinel: Any

@pytest.fixture(autouse=True)
def _bind_mocker_sentinel(self, mocker: MockerFixture) -> Generator[None, None, None]:
def _bind_mocker_sentinel(self, mocker: MockerFixture) -> Generator[None]:
self.sentinel = mocker.sentinel
yield
del self.sentinel
Expand All @@ -212,7 +212,7 @@ def protocol(
case _:
raise AssertionError("Invalid param")

def generate_chunk_side_effect(self, packet: Any) -> Generator[bytes, None, None]:
def generate_chunk_side_effect(self, packet: Any) -> Generator[bytes]:
yield self.sentinel.chunk_a
yield self.sentinel.chunk_b
yield self.sentinel.chunk_c
Expand Down
4 changes: 2 additions & 2 deletions tests/unit_test/test_serializers/test_abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

@final
class _IncrementalPacketSerializerForTest(AbstractIncrementalPacketSerializer[Any, Any]):
def incremental_serialize(self, packet: Any) -> Generator[bytes, None, None]:
def incremental_serialize(self, packet: Any) -> Generator[bytes]:
raise NotImplementedError

def incremental_deserialize(self) -> Generator[None, bytes, tuple[Any, bytes]]:
Expand All @@ -50,7 +50,7 @@ def test____serialize____concatenate_chunks(
mocker: MockerFixture,
) -> None:
# Arrange
def side_effect(_: Any) -> Generator[bytes, None, None]:
def side_effect(_: Any) -> Generator[bytes]:
yield b"a"
yield b"b"
yield b"c"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def test____send_packet____protocol_crashed(
mock_stream_transport.send_all_from_iterable.side_effect = lambda it, timeout: chunks.extend(it)
expected_error = Exception("Error")

def side_effect(packet: Any) -> Generator[bytes, None, None]:
def side_effect(packet: Any) -> Generator[bytes]:
raise expected_error
yield # type: ignore[unreachable]

Expand Down
4 changes: 2 additions & 2 deletions tests/unit_test/test_tools/test_asyncgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ async def test____anext_without_asyncgen_hook____skips_firstiter_hook(
firstiter_stub.return_value = None
sys.set_asyncgen_hooks(firstiter=firstiter_stub)

async def async_generator_function() -> AsyncGenerator[int, None]:
async def async_generator_function() -> AsyncGenerator[int]:
yield 42

async_generator = async_generator_function()
Expand All @@ -131,7 +131,7 @@ async def test____anext_without_asyncgen_hook____remove_frame_on_error() -> None
# Arrange
exc = ValueError("abc")

async def async_generator_function() -> AsyncGenerator[int, None]:
async def async_generator_function() -> AsyncGenerator[int]:
if False:
yield 42 # type: ignore[unreachable]
raise exc
Expand Down
4 changes: 2 additions & 2 deletions tests/unit_test/test_tools/test_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def test____generate____yield_generator_chunk(
mocker: MockerFixture,
) -> None:
# Arrange
def side_effect(_: Any) -> Generator[bytes, None, None]:
def side_effect(_: Any) -> Generator[bytes]:
yield b"chunk 1"
yield b"chunk 2"

Expand All @@ -78,7 +78,7 @@ def test____generate____generator_raised(
# Arrange
expected_error = Exception("Error")

def side_effect(_: Any) -> Generator[bytes, None, None]:
def side_effect(_: Any) -> Generator[bytes]:
if before_yielding:
raise expected_error
yield b"chunk"
Expand Down