https://github.com/SoftwareHeritage/swh-model
Revision e632abed41c5cd71507c4222e1e85987556b232c authored by David Douard on 13 May 2020, 15:03:01 UTC, committed by David Douard on 24 June 2020, 15:39:02 UTC
this aims at preventing constant usage of isinstance() based dispatch
code when writing generic code handling model entities.

For example, the "object_type" argument of JournalWriter.write_addition() has
become superflous now we only pass model entities, etc.

This idea comes olasd's reading of mypy doc:

  https://mypy.readthedocs.io/en/latest/literal_types.html#tagged-unions

This comes with a refactoring of from_dict.DiskBackedContent to make
it *not* inherit from model.Content: object_type being Final, it cannot
be overloaded.
1 parent 661b7c2
History
Tip revision: e632abed41c5cd71507c4222e1e85987556b232c authored by David Douard on 13 May 2020, 15:03:01 UTC
Tag model entities with their "object_type"
Tip revision: e632abe
File Mode Size
bin
docs
swh
.gitignore -rw-r--r-- 137 bytes
.pre-commit-config.yaml -rw-r--r-- 882 bytes
AUTHORS -rw-r--r-- 112 bytes
CODE_OF_CONDUCT.md -rw-r--r-- 3.3 KB
CONTRIBUTORS -rw-r--r-- 31 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-- 598 bytes
mypy.ini -rw-r--r-- 520 bytes
pyproject.toml -rw-r--r-- 39 bytes
pytest.ini -rw-r--r-- 58 bytes
requirements-cli.txt -rw-r--r-- 23 bytes
requirements-test.txt -rw-r--r-- 26 bytes
requirements.txt -rw-r--r-- 318 bytes
setup.cfg -rw-r--r-- 247 bytes
setup.py -rwxr-xr-x 2.5 KB
tox.ini -rw-r--r-- 479 bytes

README.md

back to top