Skip to content

Commit

Permalink
Remove ByteString usages
Browse files Browse the repository at this point in the history
  • Loading branch information
kg583 committed Dec 30, 2023
1 parent d8a0ed2 commit ce27135
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 15 deletions.
4 changes: 1 addition & 3 deletions tivars/tokenizer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
"""


from typing import ByteString

from tivars.data import String
from tivars.models import *
from tivars.tokens.scripts import *


def decode(bytestream: ByteString, *,
def decode(bytestream: bytes, *,
tokens: Tokens = None, lang: str = "en",
mode: str = "display") -> tuple[str | bytes, OsVersion]:
tokens = tokens or TI_84PCE.tokens
Expand Down
2 changes: 1 addition & 1 deletion tivars/tokens
6 changes: 3 additions & 3 deletions tivars/types/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import re

from io import BytesIO
from typing import ByteString, Iterator, Sequence
from typing import Iterator, Sequence
from warnings import warn

from tivars.data import *
Expand Down Expand Up @@ -88,7 +88,7 @@ class ListEntry(TIEntry):
def __init__(self, init=None, *,
for_flash: bool = True, name: str = "L1",
version: int = None, archived: bool = None,
data: ByteString = None):
data: bytes = None):

super().__init__(init, for_flash=for_flash, name=name, version=version, archived=archived, data=data)

Expand Down Expand Up @@ -156,7 +156,7 @@ def get_version(self, data: bytes = None) -> int:
def supported_by(self, model: TIModel) -> bool:
return super().supported_by(model) and (self.get_version() <= 0x0B or model.has(TIFeature.ExactMath))

@Loader[ByteString, BytesIO]
@Loader[bytes, bytearray, BytesIO]
def load_bytes(self, data: bytes | BytesIO):
super().load_bytes(data)

Expand Down
4 changes: 2 additions & 2 deletions tivars/types/matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


from io import BytesIO
from typing import ByteString, Iterator, Sequence
from typing import Iterator, Sequence
from warnings import warn

from tivars.data import *
Expand Down Expand Up @@ -132,7 +132,7 @@ def get_version(self, data: bytes = None) -> int:
def supported_by(self, model: TIModel) -> bool:
return super().supported_by(model) and (self.get_version() <= 0x0B or model.has(TIFeature.ExactMath))

@Loader[ByteString, BytesIO]
@Loader[bytes, bytearray, BytesIO]
def load_bytes(self, data: bytes | BytesIO):
super().load_bytes(data)

Expand Down
5 changes: 2 additions & 3 deletions tivars/types/tokenized.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import re

from io import BytesIO
from typing import ByteString
from warnings import warn

from tivars.data import *
Expand Down Expand Up @@ -133,7 +132,7 @@ def get_version(self, data: bytes = None) -> int:

return version

@Loader[ByteString, BytesIO]
@Loader[bytes, bytearray, BytesIO]
def load_bytes(self, data: bytes | BytesIO):
super().load_bytes(data)

Expand Down Expand Up @@ -348,7 +347,7 @@ def unprotect(self):
self.type_id = 0x05
self.coerce()

@Loader[ByteString, BytesIO]
@Loader[bytes, bytearray, BytesIO]
def load_bytes(self, data: bytes | BytesIO):
super(TokenizedEntry, self).load_bytes(data)

Expand Down
7 changes: 4 additions & 3 deletions tivars/var.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


from io import BytesIO
from typing import BinaryIO, ByteString, Iterator, Type
from typing import BinaryIO, Iterator, Type
from warnings import warn

from .data import *
Expand Down Expand Up @@ -641,7 +641,7 @@ def unarchive(self):
else:
raise TypeError("entry does not support archiving.")

@Loader[ByteString, BytesIO]
@Loader[bytes, bytearray, BytesIO]
def load_bytes(self, data: bytes | BytesIO):
"""
Loads a byte string or bytestream into this entry
Expand Down Expand Up @@ -1192,7 +1192,8 @@ def clear(self):
self.raw.calc_data.extend(bytearray(self.min_data_length - self.calc_data_length))
self.length = len(self.leading_bytes) + len(self.data)

def load_bytes(self, data: ByteString):
@Loader[bytes, bytearray, BytesIO]
def load_bytes(self, data: bytes | BytesIO):
super().load_bytes(data)

if self.length != (data_length := len(self.leading_bytes) + len(self.data)):
Expand Down

0 comments on commit ce27135

Please sign in to comment.