Skip to content

type_validator: Re-allow subclasses

The previous replaced attrs-strict's type validator with our own, stricter and faster, validator.

However, the strictness can be a burden in other packages; for example, swh-storage tests rely on it to insert dummy data that raises exception when accessed, and it would be hard to do while using the exact expected type.

This commit reverts the strict behavior, but keeps the performance optimization, by always checking with type equality, but in case type equality fails (which would raise an error before this commit), it gives the value a 'second chance', by trying isinstance.

This means that, outside tests, isinstance should not be used at all, or very rarely.


Migrated from D6387 (view on Phabricator)

Merge request reports