diff --git a/cdd/shared/pure_utils.py b/cdd/shared/pure_utils.py index 00a0aa66..16f9cf59 100644 --- a/cdd/shared/pure_utils.py +++ b/cdd/shared/pure_utils.py @@ -20,7 +20,7 @@ from sys import stderr, version_info from textwrap import fill as _fill from textwrap import indent -from typing import Any, Callable, Dict, FrozenSet, Optional, Sized, Tuple, Union, cast +from typing import Any, Callable, Dict, Optional, Sized, Tuple, Union, cast _python_major_minor: Tuple[int, int] = version_info[:2] PY3_8: bool = _python_major_minor == (3, 8) @@ -37,6 +37,11 @@ from typing_extensions import Literal, Protocol +if PY_GTE_3_9: + FrozenSet = frozenset +else: + from typing import FrozenSet + pp: Callable[[Any], None] = PrettyPrinter(indent=4, width=100, stream=stderr).pprint tab: str = environ.get("DOCTRANS_TAB", " " * 4) simple_types: Dict[Optional[str], Union[int, float, complex, str, bool, None]] = { diff --git a/cdd/sqlalchemy/utils/parse_utils.py b/cdd/sqlalchemy/utils/parse_utils.py index b60e249a..8cc19993 100644 --- a/cdd/sqlalchemy/utils/parse_utils.py +++ b/cdd/sqlalchemy/utils/parse_utils.py @@ -6,12 +6,12 @@ from ast import Assign, Call, ClassDef, Constant, Load, Module, Name from itertools import chain, filterfalse from operator import attrgetter -from typing import FrozenSet import cdd.shared.ast_utils import cdd.shared.source_transformer from cdd.shared.pure_utils import ( PY_GTE_3_8, + PY_GTE_3_9, append_to_dict, indent_all_but_first, rpartial, @@ -23,6 +23,10 @@ else: from ast import Str +if PY_GTE_3_9: + FrozenSet = frozenset +else: + from typing import FrozenSet # SQLalchemy 1.14 # `from sqlalchemy import __all__; sorted(filter(lambda s: any(filter(str.isupper, s)), __all__))` diff --git a/cdd/tests/test_compound/test_exmod.py b/cdd/tests/test_compound/test_exmod.py index 3080784c..5c587d22 100644 --- a/cdd/tests/test_compound/test_exmod.py +++ b/cdd/tests/test_compound/test_exmod.py @@ -39,7 +39,9 @@ # IntOrTupleOfStr = TypeVar("IntOrTupleOfStr", Tuple[str], int) -github_actions_and_non_windows_and_gte_3_12: bool = False +github_actions_and_non_windows_and_gte_3_12: bool = ( + "GITHUB_ACTIONS" in environ and platform != "win32" and PY_GTE_3_12 +) github_actions_err: str = "GitHub Actions fails this test (unable to replicate locally)" diff --git a/cdd/tests/test_shared/test_pkg_utils.py b/cdd/tests/test_shared/test_pkg_utils.py index 11360ddd..537c08f4 100644 --- a/cdd/tests/test_shared/test_pkg_utils.py +++ b/cdd/tests/test_shared/test_pkg_utils.py @@ -1,8 +1,9 @@ """ Tests for pkg utils """ +from site import getsitepackages from unittest import TestCase -from cdd.shared.pkg_utils import relative_filename +from cdd.shared.pkg_utils import get_python_lib, relative_filename from cdd.tests.utils_for_tests import unittest_main @@ -14,5 +15,9 @@ def test_relative_filename(self) -> None: expect: str = "gaffe" self.assertEqual(relative_filename(expect), expect) + def test_get_python_lib(self) -> None: + """Tests that `get_python_lib` works""" + self.assertEqual(getsitepackages()[0], get_python_lib()) + unittest_main()