From 21f2937bf2cebe5c8eeb7401858553f14f307dad Mon Sep 17 00:00:00 2001 From: Karolina Surma Date: Thu, 20 Feb 2025 13:47:48 +0100 Subject: [PATCH] Work around the removed typing.ByteString (Python 3.14+) --- zstandard/__init__.py | 5 ++++- zstandard/__init__.pyi | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/zstandard/__init__.py b/zstandard/__init__.py index 9c32d9d0..16075712 100644 --- a/zstandard/__init__.py +++ b/zstandard/__init__.py @@ -18,7 +18,10 @@ import io import os import platform -from typing import ByteString +from typing import Union + +# ByteString has been removed from typing in Python 3.14 +ByteString = Union[bytes, bytearray, memoryview] # Some Python implementations don't support C extensions. That's why we have # a CFFI implementation in the first place. The code here import one of our diff --git a/zstandard/__init__.pyi b/zstandard/__init__.pyi index feaad262..2d01fedd 100644 --- a/zstandard/__init__.pyi +++ b/zstandard/__init__.pyi @@ -8,7 +8,6 @@ import os from typing import ( IO, BinaryIO, - ByteString, Generator, Iterable, List, @@ -18,6 +17,9 @@ from typing import ( Union, ) +# ByteString has been removed from typing in Python 3.14 +ByteString: Union[bytes, bytearray, memoryview] + FLUSH_BLOCK: int FLUSH_FRAME: int