Closed anentropic closed 4 years ago
also, validating a type like Dict[str, Any]
gives an error:
/VENV/lib/python2.7/site-packages/attrs_strict/_type_validation.pyc in _validate_elements(attribute, value, expected_type)
35 return
36
---> 37 if base_type != typing.Union and not isinstance(value, base_type):
38 raise AttributeTypeError(value, attribute)
39
/VENV/lib/python2.7/site-packages/typing.pyc in __instancecheck__(self, obj)
632
633 def __instancecheck__(self, obj):
--> 634 raise TypeError("Any cannot be used with isinstance().")
635
636 def __subclasscheck__(self, cls):
TypeError: Any cannot be used with isinstance().
Thanks for opening this @anentropic . I'll have a look at this and come back!
@anentropic I added the MutableMapping
and Mapping
types and fixed the typing.Any
issue. Thanks for reporting this.
I'll have a sweep through the collections library and improve the support for other types existing sometimes soon.
New version available, including this changes: https://pypi.org/project/attrs-strict/
this list of types should include
typing.Mapping
Mapping[<keyT>, <valueT>]
are not caught by any of the checks so they fall-thru i.e. always succeed