Skip to content

Commit 246cc24

Browse files
authored
Merge pull request #92 from smarie/feature/91_packaging
Fixed `TypeError: Neither typeguard not pytypes is installed` even with `typeguard` installed
2 parents 67dae06 + aaaae21 commit 246cc24

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

docs/changelog.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
### 1.7.2 - bugfix
4+
5+
- Fixed `TypeError: Neither typeguard not pytypes is installed` even with `typeguard` installed.
6+
Fixed [#91] (https://github.com/smarie/python-pyfields/issues/91)
7+
38
### 1.7.1 - Compatibility fix for typeguard `3.0.0`
49

510
- Fixed `TypeError: check_type() takes 2 positional arguments but 3 were given` triggering erroneous `FieldTypeError`

pyfields/typing_utils.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ def __str__(self):
4646

4747

4848
def _make_assert_is_of_type():
49+
from packaging.version import parse as parse_version
4950
try:
5051
from typeguard import check_type as ct
51-
from packaging.version import parse as parse_version
5252

5353
# Note: only do this when we are sure that typeguard can be imported, otherwise this is slow
5454
# 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):
179179
try: # very minimal way to check if typing it available, for runtime type checking
180180
# noinspection PyUnresolvedReferences
181181
from typing import Tuple # noqa
182-
assert_is_of_type = _make_assert_is_of_type()
183182
except ImportError:
184183
assert_is_of_type = None
184+
else:
185+
assert_is_of_type = _make_assert_is_of_type()
185186

186187

187188
PY36 = sys.version_info >= (3, 6)

setup.cfg

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,15 @@ classifiers =
3232
# one day these will be able to come from requirement files, see https://github.com/pypa/setuptools/issues/1951. But will it be better ?
3333
setup_requires =
3434
setuptools_scm
35-
pytest-runner
35+
# pytest-runner
3636
install_requires =
3737
valid8>=5.0
3838
makefun
3939
# note: do not use double quotes in these, this triggers a weird bug in PyCharm in debug mode only
4040
funcsigs;python_version<'3.3'
4141
enum34;python_version<'3.4'
4242
# 'sentinel',
43+
packaging
4344
tests_require =
4445
pytest
4546
vtypes

0 commit comments

Comments
 (0)