Skip to content

Commit

Permalink
Upgrade to Python 3.9+
Browse files Browse the repository at this point in the history
  • Loading branch information
bashtage committed Sep 17, 2024
1 parent 9b01531 commit 8a5aa2d
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion randomgen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions randomgen/_pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from randomgen.xoshiro256 import Xoshiro256
from randomgen.xoshiro512 import Xoshiro512

BitGenerators: Dict[str, Type[BitGenerator]] = {
BitGenerators: dict[str, type[BitGenerator]] = {

Check warning on line 29 in randomgen/_pickle.py

View check run for this annotation

Codecov / codecov/patch

randomgen/_pickle.py#L29

Added line #L29 was not covered by tests
"AESCounter": AESCounter,
"ChaCha": ChaCha,
"LCG128Mix": LCG128Mix,
Expand Down Expand Up @@ -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]:

Check warning on line 61 in randomgen/_pickle.py

View check run for this annotation

Codecov / codecov/patch

randomgen/_pickle.py#L61

Added line #L61 was not covered by tests
"""
Bit generator look-up with user-friendly errors
"""
Expand Down
4 changes: 2 additions & 2 deletions randomgen/src/mt19937/generate-jump-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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"
Expand Down
8 changes: 4 additions & 4 deletions randomgen/tests/test_direct.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,)
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -775,7 +775,7 @@ def test_advance(self):


class TestPCG64XSLRR(Base):
bit_generator: Type[PCG64]
bit_generator: type[PCG64]

@classmethod
def setup_class(cls):
Expand Down
2 changes: 1 addition & 1 deletion randomgen/tests/test_stability.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
3 changes: 2 additions & 1 deletion randomgen/typing.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down

0 comments on commit 8a5aa2d

Please sign in to comment.