diff --git a/docs/changelog.md b/docs/changelog.md index 216e3b5..abd6a47 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,5 +1,10 @@ # Changelog +### 1.7.2 - bugfix + + - Fixed `TypeError: Neither typeguard not pytypes is installed` even with `typeguard` installed. + Fixed [#91] (https://github.com/smarie/python-pyfields/issues/91) + ### 1.7.1 - Compatibility fix for typeguard `3.0.0` - Fixed `TypeError: check_type() takes 2 positional arguments but 3 were given` triggering erroneous `FieldTypeError` diff --git a/pyfields/typing_utils.py b/pyfields/typing_utils.py index 5fcbfdb..fed3ca1 100644 --- a/pyfields/typing_utils.py +++ b/pyfields/typing_utils.py @@ -46,9 +46,9 @@ def __str__(self): def _make_assert_is_of_type(): + from packaging.version import parse as parse_version try: from typeguard import check_type as ct - from packaging.version import parse as parse_version # Note: only do this when we are sure that typeguard can be imported, otherwise this is slow # see https://github.com/smarie/python-getversion/blob/ee495acf6cf06c5e860713edeee396206368e458/getversion/main.py#L84 @@ -179,9 +179,10 @@ def assert_is_of_type(field, value, typ): try: # very minimal way to check if typing it available, for runtime type checking # noinspection PyUnresolvedReferences from typing import Tuple # noqa - assert_is_of_type = _make_assert_is_of_type() except ImportError: assert_is_of_type = None +else: + assert_is_of_type = _make_assert_is_of_type() PY36 = sys.version_info >= (3, 6) diff --git a/setup.cfg b/setup.cfg index 200fec6..129f310 100644 --- a/setup.cfg +++ b/setup.cfg @@ -32,7 +32,7 @@ classifiers = # one day these will be able to come from requirement files, see https://github.com/pypa/setuptools/issues/1951. But will it be better ? setup_requires = setuptools_scm - pytest-runner + # pytest-runner install_requires = valid8>=5.0 makefun @@ -40,6 +40,7 @@ install_requires = funcsigs;python_version<'3.3' enum34;python_version<'3.4' # 'sentinel', + packaging tests_require = pytest vtypes