1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-15 00:05:11 +02:00

Adjust for removal of typing.ByteString in Python 3.14 (#639)

`typing.ByteString` has been removed:

https://docs.python.org/3.14/whatsnew/3.14.html

The modernizing guide suggests `collections.abc.ByteString` which has
also been removed; the recommendation is to use either:

- just `bytes`
- `collections.abc.Buffer`
- a union of `bytes`, `bytesarray`, etc.

https://typing.readthedocs.io/en/latest/guides/modernizing.html#modernizing-byte-string

Per discussion, using `bytes` should suffice

Signed-off-by: Michel Lind <salimma@fedoraproject.org>
This commit is contained in:
Michel Lind
2025-03-30 14:34:54 -05:00
committed by GitHub
parent 896891ad9e
commit fb4b4eeb58
2 changed files with 7 additions and 8 deletions

View File

@ -4,7 +4,6 @@ Edid module
import struct import struct
from collections import namedtuple from collections import namedtuple
from typing import ByteString
__all__ = ["Edid"] __all__ = ["Edid"]
@ -108,10 +107,10 @@ class Edid:
), ),
) )
def __init__(self, edid: ByteString): def __init__(self, edid: bytes):
self._parse_edid(edid) self._parse_edid(edid)
def _parse_edid(self, edid: ByteString): def _parse_edid(self, edid: bytes):
"""Convert edid byte string to edid object""" """Convert edid byte string to edid object"""
if struct.calcsize(self._STRUCT_FORMAT) != 128: if struct.calcsize(self._STRUCT_FORMAT) != 128:
raise ValueError("Wrong edid size.") raise ValueError("Wrong edid size.")

View File

@ -3,7 +3,7 @@ EDID helper
""" """
from subprocess import CalledProcessError, check_output from subprocess import CalledProcessError, check_output
from typing import ByteString, List from typing import List
__all__ = ["EdidHelper"] __all__ = ["EdidHelper"]
@ -12,14 +12,14 @@ class EdidHelper:
"""Class for working with EDID data""" """Class for working with EDID data"""
@staticmethod @staticmethod
def hex2bytes(hex_data: str) -> ByteString: def hex2bytes(hex_data: str) -> bytes:
"""Convert hex EDID string to bytes """Convert hex EDID string to bytes
Args: Args:
hex_data (str): hex edid string hex_data (str): hex edid string
Returns: Returns:
ByteString: edid byte string bytes: edid byte string
""" """
# delete edid 1.3 additional block # delete edid 1.3 additional block
if len(hex_data) > 256: if len(hex_data) > 256:
@ -32,14 +32,14 @@ class EdidHelper:
return bytes(numbers) return bytes(numbers)
@classmethod @classmethod
def get_edids(cls) -> List[ByteString]: def get_edids(cls) -> List[bytes]:
"""Get edids from xrandr """Get edids from xrandr
Raises: Raises:
`RuntimeError`: if error with retrieving xrandr util data `RuntimeError`: if error with retrieving xrandr util data
Returns: Returns:
List[ByteString]: list with edids List[bytes]: list with edids
""" """
try: try:
output = check_output(["xrandr", "--verbose"]) output = check_output(["xrandr", "--verbose"])