Type Model Visitor
TMV (Type Model Visitor)
Visitor for type models using typing annotations.
The package contains an abstract
Visitor class which needs by-type methods implementation. Only (some of) the standard types are supported:
- primitives (
Annotated(PEP 593), etc.
Unsupported types are handled in
unsupported method, of which default implementation raises
Visitor offers support for custom types through 2 methods
custom. The return value of
is_custom is passed to
custom when evaluated to
True; it's thus convenient to use an optional return type. Customs types are handled before others classes like dataclasses or enumerations (to enable custom handling for them).
See apischema for concrete use of the package
- If an abstract class was at first considered for
NotImplementedErrorhas been chosen because it enable an easier use, especially in case of partial implementation (which would imply to overwrite with
NotImplementedErrorin case of
- For convenience, inheritance is not handled in this project. In fact, if
__orig_bases__could be used, this would raises other issues like multiple inheritance. Moreover, some implementation could rely on
__init__method (it's the case apischema from which this project was originally extracted), and inheritance makes things fuzzy on this point.
- Customs type could be handled in an overwrite of
unsupportedmethod, but this would make impossible to handle custom dataclasses, that's why a dedicated method is used
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size tmv-0.1.3-py3-none-any.whl (4.5 kB)||File type Wheel||Python version py3||Upload date||Hashes View hashes|
|Filename, size tmv-0.1.3.tar.gz (3.6 kB)||File type Source||Python version None||Upload date||Hashes View hashes|