https://github.com/SoftwareHeritage/swh-model
Revision 916627e1b504cbe696f71be5960ab34711cd03da authored by Valentin Lorentz on 01 October 2021, 12:19:48 UTC, committed by Valentin Lorentz on 01 October 2021, 12:31:41 UTC
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.
1 parent 734b081
History
Tip revision: 916627e1b504cbe696f71be5960ab34711cd03da authored by Valentin Lorentz on 01 October 2021, 12:19:48 UTC
type_validator: Re-allow subclasses
Tip revision: 916627e
File Mode Size
bin
docs
swh
.gitignore -rw-r--r-- 137 bytes
.pre-commit-config.yaml -rw-r--r-- 1021 bytes
AUTHORS -rw-r--r-- 112 bytes
CODE_OF_CONDUCT.md -rw-r--r-- 3.3 KB
CONTRIBUTORS -rw-r--r-- 45 bytes
LICENSE -rw-r--r-- 34.3 KB
MANIFEST.in -rw-r--r-- 157 bytes
Makefile -rw-r--r-- 163 bytes
Makefile.local -rw-r--r-- 24 bytes
README.md -rw-r--r-- 620 bytes
mypy.ini -rw-r--r-- 571 bytes
pyproject.toml -rw-r--r-- 237 bytes
pytest.ini -rw-r--r-- 247 bytes
requirements-cli.txt -rw-r--r-- 30 bytes
requirements-test.txt -rw-r--r-- 51 bytes
requirements.txt -rw-r--r-- 380 bytes
setup.cfg -rw-r--r-- 247 bytes
setup.py -rwxr-xr-x 2.5 KB
tox.ini -rw-r--r-- 1.7 KB

README.md

back to top