You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TypeError "Neither typeguard not pytypes is installed"... but typeguard is installed #91
We sometimes encounter this error on minimalistic environments:
Traceback (most recent call last):
File "C:\<env_path>\lib\site-packages\pyfields\typing_utils.py", line 165, in assert_is_of_type
is_ok = isinstance(value, types)
File "C:\Python39\lib\typing.py", line 720, in __instancecheck__
return self.__subclasscheck__(type(obj))
File "C:\Python39\lib\typing.py", line 723, in __subclasscheck__
raise TypeError("Subscripted generics cannot be used with"
TypeError: Subscripted generics cannot be used with class and instance checks
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\<env_path>\lib\site-packages\dq4ts\description.py", line 128, in from_dict
fields[f.name] = dict_to_pyfields(field_dct, f.type_hint)
File "C:\<env_path>\lib\site-packages\dq4ts\utils_pyfields.py", line 74, in dict_to_pyfields
return create_pyfields_instance(cls, init_kwargs)
File "C:\<env_path>\lib\site-packages\dq4ts\utils_pyfields.py", line 92, in create_pyfields_instance
return cls(**init_kwargs)
File "<makefun-gen-15>", line 2, in __init__
File "C:\<env_path>\lib\site-packages\pyfields\init_makers.py", line 409, in init_fun
setattr(self, field_name, field_value)
File "C:\<env_path>\lib\site-packages\pyfields\core.py", line 1127, in __set__
assert_is_of_type(self, value, t)
File "C:\<env_path>\lib\site-packages\pyfields\typing_utils.py", line 168, in assert_is_of_type
raise TypeError("Neither typeguard not pytypes is installed - therefore it is not possible to "
TypeError: not all arguments converted during string formatting
Even if typeguard is installed.
This error is actually due to the absence of packaging module. The fix is therefore to do
> pip install packaging
We should add it to the requirements of this package so that this is automatic in the future.
Activity
smarie commentedon Nov 6, 2023
The culprit is this line : https://github.com/smarie/python-pyfields/blob/main/pyfields/typing_utils.py#L51
The import statement should move outside of the try except loop !
Fixed `TypeError: Neither typeguard not pytypes is installed` even wi…