Skip to content

Commit

Permalink
Adjust for removal of typing.ByteString in Python 3.14
Browse files Browse the repository at this point in the history
`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>
  • Loading branch information
michel-slm committed Feb 10, 2025
1 parent 7fda79d commit d8342a4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
5 changes: 2 additions & 3 deletions jc/parsers/pyedid/edid.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import struct
from collections import namedtuple
from typing import ByteString

__all__ = ["Edid"]

Expand Down Expand Up @@ -108,10 +107,10 @@ class Edid:
),
)

def __init__(self, edid: ByteString):
def __init__(self, edid: bytes):
self._parse_edid(edid)

def _parse_edid(self, edid: ByteString):
def _parse_edid(self, edid: bytes):
"""Convert edid byte string to edid object"""
if struct.calcsize(self._STRUCT_FORMAT) != 128:
raise ValueError("Wrong edid size.")
Expand Down
10 changes: 5 additions & 5 deletions jc/parsers/pyedid/helpers/edid_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""

from subprocess import CalledProcessError, check_output
from typing import ByteString, List
from typing import List

__all__ = ["EdidHelper"]

Expand All @@ -12,14 +12,14 @@ class EdidHelper:
"""Class for working with EDID data"""

@staticmethod
def hex2bytes(hex_data: str) -> ByteString:
def hex2bytes(hex_data: str) -> bytes:
"""Convert hex EDID string to bytes
Args:
hex_data (str): hex edid string
Returns:
ByteString: edid byte string
bytes: edid byte string
"""
# delete edid 1.3 additional block
if len(hex_data) > 256:
Expand All @@ -32,14 +32,14 @@ def hex2bytes(hex_data: str) -> ByteString:
return bytes(numbers)

@classmethod
def get_edids(cls) -> List[ByteString]:
def get_edids(cls) -> List[bytes]:
"""Get edids from xrandr
Raises:
`RuntimeError`: if error with retrieving xrandr util data
Returns:
List[ByteString]: list with edids
List[bytes]: list with edids
"""
try:
output = check_output(["xrandr", "--verbose"])
Expand Down

0 comments on commit d8342a4

Please sign in to comment.