From 5c0143560d4e2aa2392207f43389fb76c0402b4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Forr=C3=B3?= Date: Wed, 30 Oct 2024 15:53:30 +0100 Subject: [PATCH 1/2] Remove deprecated `ByteString` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `ByteString` has been deprecated in Python 3.12 and will be removed in Python 3.14. Replace it with `Union[bytes, bytearray]`. Signed-off-by: Nikola Forró --- awscrt/eventstream/__init__.py | 7 +++---- awscrt/eventstream/rpc.py | 8 ++++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/awscrt/eventstream/__init__.py b/awscrt/eventstream/__init__.py index 09e24ada4..945027527 100644 --- a/awscrt/eventstream/__init__.py +++ b/awscrt/eventstream/__init__.py @@ -5,9 +5,8 @@ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # SPDX-License-Identifier: Apache-2.0. -from collections.abc import ByteString from enum import IntEnum -from typing import Any +from typing import Any, Union from uuid import UUID __all__ = ['HeaderType', 'Header'] @@ -135,7 +134,7 @@ def from_int64(cls, name: str, value: int) -> 'Header': return cls(name, value, HeaderType.INT64) @classmethod - def from_byte_buf(cls, name: str, value: ByteString) -> 'Header': + def from_byte_buf(cls, name: str, value: Union[bytes, bytearray]) -> 'Header': """Create a Header of type :attr:`~HeaderType.BYTE_BUF` The value must be a bytes-like object""" @@ -246,7 +245,7 @@ def value_as_int64(self) -> int: Raises an exception if type is not :attr:`~HeaderType.INT64`""" return self._value_as(HeaderType.INT64) - def value_as_byte_buf(self) -> ByteString: + def value_as_byte_buf(self) -> Union[bytes, bytearray]: """Return value of bytes Raises an exception if type is not :attr:`~HeaderType.BYTE_BUF`""" diff --git a/awscrt/eventstream/rpc.py b/awscrt/eventstream/rpc.py index b70352e02..449a3187e 100644 --- a/awscrt/eventstream/rpc.py +++ b/awscrt/eventstream/rpc.py @@ -11,7 +11,7 @@ import awscrt.exceptions from awscrt.eventstream import Header from awscrt.io import ClientBootstrap, SocketOptions, TlsConnectionOptions -from collections.abc import ByteString, Callable +from collections.abc import Callable, Union from concurrent.futures import Future from enum import IntEnum from functools import partial @@ -381,7 +381,7 @@ def send_protocol_message( self, *, headers: Optional[Sequence[Header]] = None, - payload: Optional[ByteString] = None, + payload: Optional[Union[bytes, bytearray]] = None, message_type: MessageType, flags: Optional[int] = None, on_flush: Callable = None) -> 'concurrent.futures.Future': @@ -483,7 +483,7 @@ def activate( *, operation: str, headers: Sequence[Header] = None, - payload: ByteString = None, + payload: Union[bytes, bytearray] = None, message_type: MessageType, flags: int = None, on_flush: Callable = None): @@ -553,7 +553,7 @@ def send_message( self, *, headers: Sequence[Header] = None, - payload: ByteString = None, + payload: Union[bytes, bytearray] = None, message_type: MessageType, flags: int = None, on_flush: Callable = None) -> 'concurrent.futures.Future': From 4d3ff2c0b6c39c2ebb0aeca2b44adeb1fd25f206 Mon Sep 17 00:00:00 2001 From: Michael Graeb Date: Wed, 30 Oct 2024 10:07:31 -0700 Subject: [PATCH 2/2] Fix import of Union --- awscrt/eventstream/rpc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/awscrt/eventstream/rpc.py b/awscrt/eventstream/rpc.py index 449a3187e..ff0096e26 100644 --- a/awscrt/eventstream/rpc.py +++ b/awscrt/eventstream/rpc.py @@ -11,11 +11,11 @@ import awscrt.exceptions from awscrt.eventstream import Header from awscrt.io import ClientBootstrap, SocketOptions, TlsConnectionOptions -from collections.abc import Callable, Union +from collections.abc import Callable from concurrent.futures import Future from enum import IntEnum from functools import partial -from typing import Optional, Sequence +from typing import Optional, Sequence, Union __all__ = [ 'MessageType',