HomeSoftware Heritage

type_validator: Re-allow subclasses

This commit no longer exists in the repository. It may have been part of a branch which was deleted.

Description

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.

Details

Provenance
vlorentzAuthored on Oct 1 2021, 2:19 PM
vlorentzPushed on Oct 5 2021, 11:21 AM
Differential Revision
D6387: type_validator: Re-allow subclasses
Build Status
Buildable 24212
Build 37791: test-and-buildJenkins console · Jenkins

Commit No Longer Exists

This commit no longer exists in the repository.