Skip to content

Commit

Permalink
Fixed TypeError: Neither typeguard not pytypes is installed even wi…
Browse files Browse the repository at this point in the history
…th `typeguard` installed. Fixed #91
  • Loading branch information
Sylvain MARIE committed Nov 6, 2023
1 parent 67dae06 commit aaaae21
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -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`
Expand Down
5 changes: 3 additions & 2 deletions pyfields/typing_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@ 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
# note: do not use double quotes in these, this triggers a weird bug in PyCharm in debug mode only
funcsigs;python_version<'3.3'
enum34;python_version<'3.4'
# 'sentinel',
packaging
tests_require =
pytest
vtypes
Expand Down

0 comments on commit aaaae21

Please sign in to comment.