diff --git a/tivars/data.py b/tivars/data.py index f2be8d1..0885714 100644 --- a/tivars/data.py +++ b/tivars/data.py @@ -25,8 +25,9 @@ import copy import inspect +from collections.abc import Callable from math import ceil -from typing import Callable, TypeVar +from typing import TypeVar from warnings import warn diff --git a/tivars/flags.py b/tivars/flags.py index 8c10747..39eae34 100644 --- a/tivars/flags.py +++ b/tivars/flags.py @@ -13,9 +13,9 @@ """ +from collections.abc import Mapping from functools import total_ordering from math import ceil -from typing import Mapping from warnings import warn from .data import * @@ -80,7 +80,7 @@ class Flags(Converter, dict, Mapping[int, int]): _T = 'Flags' - def __init__(self, bitsets: Mapping[int, int] | 'Flags' = None, *, width: int = 8): + def __init__(self, bitsets: Mapping[int, int] = None, *, width: int = 8): """ Creates an empty `Flags` instance with a given initial state and width @@ -105,7 +105,7 @@ def __int__(self) -> int: def __str__(self) -> str: return ''.join([str(bit) for bit in self.values()][::-1]) - def __contains__(self, bitsets: Mapping[int, int] | 'Flags') -> bool: + def __contains__(self, bitsets: Mapping[int, int]) -> bool: return all(self[bit] == int(bool(bitsets[bit])) for bit in bitsets) has = __contains__ diff --git a/tivars/flash.py b/tivars/flash.py index ce44efb..8de7391 100644 --- a/tivars/flash.py +++ b/tivars/flash.py @@ -5,7 +5,7 @@ from io import BytesIO from sys import version_info -from typing import BinaryIO, Type +from typing import BinaryIO from warnings import warn from .data import * @@ -556,7 +556,7 @@ def checksum(self) -> bytes: return self.raw.checksum @classmethod - def get_type(cls, type_id: int) -> Type['TIFlashHeader'] | None: + def get_type(cls, type_id: int) -> type['TIFlashHeader'] | None: """ Gets the subclass corresponding to a type ID if one is registered @@ -595,7 +595,7 @@ def next_header_length(stream: BinaryIO) -> int: return entry_length @classmethod - def register(cls, var_type: Type['TIFlashHeader'], override: int = None): + def register(cls, var_type: type['TIFlashHeader'], override: int = None): """ Registers a subtype with this class for coercion diff --git a/tivars/types/complex.py b/tivars/types/complex.py index b2087eb..2467b76 100644 --- a/tivars/types/complex.py +++ b/tivars/types/complex.py @@ -3,7 +3,6 @@ """ -from typing import Type from warnings import warn from tivars.data import * @@ -204,7 +203,7 @@ def imag_sign_bit(self) -> int: """ @property - def real_type(self) -> Type['RealEntry']: + def real_type(self) -> type['RealEntry']: """ :return: The subclass of `RealEntry` corresponding to this entry's `real_subtype_id`. """ @@ -212,7 +211,7 @@ def real_type(self) -> Type['RealEntry']: return self.get_type(self.real_subtype_id).real_analogue @property - def imag_type(self) -> Type['RealEntry']: + def imag_type(self) -> type['RealEntry']: """ :return: The subclass of `RealEntry` corresponding to this entry's `imag_subtype_id`. """ diff --git a/tivars/types/gdb.py b/tivars/types/gdb.py index 7f3fb62..07eab1a 100644 --- a/tivars/types/gdb.py +++ b/tivars/types/gdb.py @@ -6,8 +6,8 @@ import json import os +from collections.abc import Iterator from io import BytesIO -from typing import Iterator from warnings import catch_warnings, filterwarnings, warn from tivars.flags import * diff --git a/tivars/types/group.py b/tivars/types/group.py index 64177c1..467873c 100644 --- a/tivars/types/group.py +++ b/tivars/types/group.py @@ -3,8 +3,8 @@ """ +from collections.abc import Sequence from io import BytesIO -from typing import Sequence from warnings import warn from tivars.data import * diff --git a/tivars/types/list.py b/tivars/types/list.py index a4ec1bb..998f74a 100644 --- a/tivars/types/list.py +++ b/tivars/types/list.py @@ -5,8 +5,8 @@ import re +from collections.abc import Iterator, Sequence from io import BytesIO -from typing import Iterator, Sequence from warnings import warn from tivars.data import * diff --git a/tivars/types/matrix.py b/tivars/types/matrix.py index eedbc06..9eaf849 100644 --- a/tivars/types/matrix.py +++ b/tivars/types/matrix.py @@ -3,8 +3,8 @@ """ +from collections.abc import Iterator, Sequence from io import BytesIO -from typing import Iterator, Sequence from warnings import warn from tivars.data import * diff --git a/tivars/types/picture.py b/tivars/types/picture.py index 5ec02d5..a400d5e 100644 --- a/tivars/types/picture.py +++ b/tivars/types/picture.py @@ -4,7 +4,9 @@ import re -from typing import Iterator, Sequence + + +from collections.abc import Iterator, Sequence from warnings import warn from tivars.data import * diff --git a/tivars/types/real.py b/tivars/types/real.py index d426acc..fac73d7 100644 --- a/tivars/types/real.py +++ b/tivars/types/real.py @@ -8,7 +8,6 @@ from decimal import Decimal, localcontext from fractions import Fraction -from typing import Type from warnings import warn from tivars.data import * @@ -114,7 +113,7 @@ def sign_bit(self) -> int: """ @property - def subtype(self) -> Type['RealEntry']: + def subtype(self) -> type['RealEntry']: """ :return: The subtype of this real number """ diff --git a/tivars/var.py b/tivars/var.py index 3acf4ae..cf92cad 100644 --- a/tivars/var.py +++ b/tivars/var.py @@ -3,9 +3,10 @@ """ +from collections.abc import Iterator from io import BytesIO from sys import version_info -from typing import BinaryIO, Iterator, Type +from typing import BinaryIO from warnings import warn from .data import * @@ -566,7 +567,7 @@ def meta(self) -> bytes: return self.raw.calc_data_length + self.raw.type_id + self.raw.name + self.raw.version + self.raw.archived @classmethod - def get_type(cls, type_id: int) -> Type['TIEntry'] | None: + def get_type(cls, type_id: int) -> type['TIEntry'] | None: """ Gets the subclass corresponding to a type ID if one is registered @@ -592,7 +593,7 @@ def next_entry_length(stream: BinaryIO) -> int: return 2 + meta_length + 2 + data_length @classmethod - def register(cls, var_type: Type['TIEntry'], override: int = None): + def register(cls, var_type: type['TIEntry'], override: int = None): """ Registers a subtype with this class for coercion