From 5579f9ff5312147bf9bde8f5e58486aed7868f2a Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Tue, 27 Apr 2021 23:44:15 +0100 Subject: [PATCH] MAINT: Restore 3.6 functionality --- ci/azure/azure_template_posix.yml | 2 ++ randomgen/tests/test_recent_numpy_changes.py | 2 -- randomgen/typing.py | 21 ++++++++++++++------ randomgen/xoshiro256starstar.py | 2 -- randomgen/xoshiro512starstar.py | 2 -- requirements-dev.txt | 1 + 6 files changed, 18 insertions(+), 12 deletions(-) diff --git a/ci/azure/azure_template_posix.yml b/ci/azure/azure_template_posix.yml index d0b50f3a5..2e6d313e2 100644 --- a/ci/azure/azure_template_posix.yml +++ b/ci/azure/azure_template_posix.yml @@ -28,6 +28,8 @@ jobs: NUMPY: 1.16.6 python39_latest: python.version: '3.9' + python36_latest: + python.version: '3.6' python38_mid_conda: python.version: '3.8' use.conda: true diff --git a/randomgen/tests/test_recent_numpy_changes.py b/randomgen/tests/test_recent_numpy_changes.py index 9e4bf78f9..0562e5295 100644 --- a/randomgen/tests/test_recent_numpy_changes.py +++ b/randomgen/tests/test_recent_numpy_changes.py @@ -1,5 +1,3 @@ -from __future__ import annotations - from distutils.version import LooseVersion from typing import cast diff --git a/randomgen/typing.py b/randomgen/typing.py index 6e27199c1..bf3eacb81 100644 --- a/randomgen/typing.py +++ b/randomgen/typing.py @@ -1,13 +1,22 @@ -from typing import TYPE_CHECKING, Any, Optional, Sequence, Union +import sys +from typing import TYPE_CHECKING, Optional, Sequence, Union -if TYPE_CHECKING: - from typing import Literal +from randomgen.seed_sequence import SeedSequence - SeedMode = Literal["sequence", "legacy"] +if sys.version_info >= (3, 8): + from typing import Literal +elif TYPE_CHECKING: + from typing_extensions import Literal else: - SeedMode = Any -from randomgen.seed_sequence import SeedSequence + class _Literal: + def __getitem__(self, item): + pass + + Literal = _Literal() + +SeedMode = Literal["sequence", "legacy"] + __all__ = ["IntegerSequenceSeed", "SeedMode", "Size"] diff --git a/randomgen/xoshiro256starstar.py b/randomgen/xoshiro256starstar.py index 0c7cde4f5..59d14131f 100644 --- a/randomgen/xoshiro256starstar.py +++ b/randomgen/xoshiro256starstar.py @@ -1,5 +1,3 @@ -from __future__ import annotations - from typing import Optional import warnings diff --git a/randomgen/xoshiro512starstar.py b/randomgen/xoshiro512starstar.py index eda1107b5..cb5b88207 100644 --- a/randomgen/xoshiro512starstar.py +++ b/randomgen/xoshiro512starstar.py @@ -1,5 +1,3 @@ -from __future__ import annotations - from typing import Optional import warnings diff --git a/requirements-dev.txt b/requirements-dev.txt index acc919f30..9360def19 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,3 +1,4 @@ +black==21.4b1 pytest>=6 pytest-cov scipy>=1.3.2 \ No newline at end of file