Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed TypeError: Neither typeguard not pytypes is installed even with typeguard installed #92

Merged
merged 1 commit into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading