Skip to content

Commit

Permalink
Remove deprecated ByteString (#608)
Browse files Browse the repository at this point in the history
`ByteString` has been deprecated in Python 3.12 and will be removed in Python 3.14. Replace it with `Union[bytes, bytearray]`.

See: https://docs.python.org/dev/deprecations/pending-removal-in-3.14.html
  • Loading branch information
nforro authored Oct 30, 2024
1 parent e9c64a3 commit 084e141
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
7 changes: 3 additions & 4 deletions awscrt/eventstream/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down Expand Up @@ -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"""
Expand Down Expand Up @@ -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`"""
Expand Down
10 changes: 5 additions & 5 deletions awscrt/eventstream/rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
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
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',
Expand Down Expand Up @@ -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':
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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':
Expand Down

0 comments on commit 084e141

Please sign in to comment.