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
If I have a Nonable field, setting it to None, or calling a constructor with the field unspecified should not raise a validation error. However, this happens if I have typegaurd installed
Example code to reproduce:
class A:
f: str = field(check_type=True, default=None, nonable=True)
@init_fields
def __init__():
pass
a = A()
This results in the following traceback:
raceback (most recent call last):
File "/Users/devashishshankar/Work/ddp_v1_venv/lib/python3.7/site-packages/pyfields/typing_utils.py", line 58, in assert_is_of_type
check_type(field.qualname, value, typ)
File "/Users/devashishshankar/Work/ddp_v1_venv/lib/python3.7/site-packages/typeguard/__init__.py", line 544, in check_type
format(argname, qualified_name(expected_type), qualified_name(value)))
TypeError: type of A.f must be str; got NoneType instead
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<makefun-gen-36>", line 2, in __init__
File "/Users/devashishshankar/Work/ddp_v1_venv/lib/python3.7/site-packages/pyfields/init_makers.py", line 446, in __init__
setattr(self, field_name, field_value)
File "/Users/devashishshankar/Work/ddp_v1_venv/lib/python3.7/site-packages/pyfields/core.py", line 1066, in __set__
assert_is_of_type(self, value, t)
File "/Users/devashishshankar/Work/ddp_v1_venv/lib/python3.7/site-packages/pyfields/typing_utils.py", line 63, in assert_is_of_type
raise new_e
pyfields.typing_utils.FieldTypeError: Invalid value type provided for 'A.f'. Value should be of type <class 'str'>. Instead, received a 'NoneType': None
The text was updated successfully, but these errors were encountered:
If I have a Nonable field, setting it to None, or calling a constructor with the field unspecified should not raise a validation error. However, this happens if I have
typegaurd
installedExample code to reproduce:
This results in the following traceback:
The text was updated successfully, but these errors were encountered: