diff --git a/randomgen/__init__.py b/randomgen/__init__.py index d3a161806..85938ee86 100644 --- a/randomgen/__init__.py +++ b/randomgen/__init__.py @@ -76,7 +76,7 @@ ] -def test(extra_args: Union[str, List[str]] = None) -> None: +def test(extra_args: Union[str, list[str]] = None) -> None: try: import pytest except ImportError as err: diff --git a/randomgen/_pickle.py b/randomgen/_pickle.py index dea88d0ef..9e6ff694d 100644 --- a/randomgen/_pickle.py +++ b/randomgen/_pickle.py @@ -26,7 +26,7 @@ from randomgen.xoshiro256 import Xoshiro256 from randomgen.xoshiro512 import Xoshiro512 -BitGenerators: Dict[str, Type[BitGenerator]] = { +BitGenerators: dict[str, type[BitGenerator]] = { "AESCounter": AESCounter, "ChaCha": ChaCha, "LCG128Mix": LCG128Mix, @@ -58,7 +58,7 @@ BitGenerators[f"{value.__module__}.{value.__name__}"] = value -def _get_bitgenerator(bit_generator_name: str) -> Type[BitGenerator]: +def _get_bitgenerator(bit_generator_name: str) -> type[BitGenerator]: """ Bit generator look-up with user-friendly errors """ diff --git a/randomgen/src/mt19937/generate-jump-test.py b/randomgen/src/mt19937/generate-jump-test.py index 5bd756b45..bf74468e6 100644 --- a/randomgen/src/mt19937/generate-jump-test.py +++ b/randomgen/src/mt19937/generate-jump-test.py @@ -45,7 +45,7 @@ def save_state(bit_gen: MT19937, file_name: str) -> None: f.write(f"{state_pos}\n") -def parse_output(text: str) -> Tuple[List[Dict[str, Union[List, int]]], List[int]]: +def parse_output(text: str) -> tuple[list[dict[str, Union[list, int]]], list[int]]: lines = text.split("\n") key_list: list[int] = [] output_state = {"key": key_list, "pos": -1} @@ -66,7 +66,7 @@ def parse_output(text: str) -> Tuple[List[Dict[str, Union[List, int]]], List[int return states[:-1], pf -values: Dict[Tuple[str, Tuple[int, ...], int], Dict] = {} +values: dict[tuple[str, tuple[int, ...], int], dict] = {} for poly in ("poly-128", "clist_mt19937"): shutil.copy(f"{poly}.txt", "jump-poly.txt") fn = "_jump_tester" if poly == "clist_mt19937" else "jumped" diff --git a/randomgen/tests/test_direct.py b/randomgen/tests/test_direct.py index 56d79175f..36e8c4e29 100644 --- a/randomgen/tests/test_direct.py +++ b/randomgen/tests/test_direct.py @@ -74,7 +74,7 @@ except ImportError: MISSING_CTYPES = False -ISEED_SEQUENCES: Tuple[Any, ...] = (ISeedSequence,) +ISEED_SEQUENCES: tuple[Any, ...] = (ISeedSequence,) # NumPy 1.17 try: ISEED_SEQUENCES += (np.random.bit_generator.ISeedSequence,) @@ -197,8 +197,8 @@ def gauss_from_uint(x, n, bits): class Base: dtype = np.uint64 - data2: Dict[str, Union[int, np.ndarray]] = {} - data1: Dict[str, Union[int, np.ndarray]] = {} + data2: dict[str, Union[int, np.ndarray]] = {} + data1: dict[str, Union[int, np.ndarray]] = {} @classmethod def setup_class(cls): @@ -775,7 +775,7 @@ def test_advance(self): class TestPCG64XSLRR(Base): - bit_generator: Type[PCG64] + bit_generator: type[PCG64] @classmethod def setup_class(cls): diff --git a/randomgen/tests/test_stability.py b/randomgen/tests/test_stability.py index 1ab5fe22a..6a464c6f2 100644 --- a/randomgen/tests/test_stability.py +++ b/randomgen/tests/test_stability.py @@ -23,7 +23,7 @@ minimal_keys.append(key) minimal_ids.append(test_id) -EXECUTED: Dict[Tuple[str, str], Dict[str, str]] = {} +EXECUTED: dict[tuple[str, str], dict[str, str]] = {} @pytest.fixture(params=all_keys, ids=all_ids, scope="module") diff --git a/randomgen/typing.py b/randomgen/typing.py index 160c7cbb5..cdc025e97 100644 --- a/randomgen/typing.py +++ b/randomgen/typing.py @@ -1,4 +1,5 @@ -from typing import Literal, Optional, Sequence, Union +from typing import Literal, Optional, Union +from collections.abc import Sequence from randomgen.seed_sequence import SeedSequence