Releases: 6r17/madtypes
v0.0.9
Refactor
What's Changed
Woaw ! This is a major refactor of the project. It piled up a bunch of features together from v0.0.1 to v0.0.7 and when I added the Annotation metaclass I realized how the project should've been properly written in the first place. There are few elements that have been dropped in favor of a overall more solid proposed code, for instance Immutable are not really the first aim of this package and since I didn't have put much mind into it, I didn't want to encourage it's usage.
However, I believe the new MadType metaclass should be the correct pythonic way of adding this feature in Python. The code feels way more maintainable now, and I'm really happy to put this release out so early :)
I'm not bumping into a 1.0.0 straight away, i'd like the software to live a little bit longer, it might get to 0.1.0 if a few weeks if the code looks stable.
Enjoy !
- Annotation support for dict by @6r17 in #6
- 💢
Annotationis renamedMadType - 🤓
MadTypesupport fordict. ⚠️ dropImmutablesince it's a poor proposal.⚠️ dropSchemain favor of(dict, metaclass=MadType).- 🛠️ refactor of tests which are now organized between integrity and json_schema
- ⚒️
__init__can be safely overwritten and type-check will still apply inside of it
- 💢
Full Changelog: v0.0.7...v0.0.8
Subtraction
What's Changed
- Field subtraction by @6r17 in #7
- 🆕 subtract_fields (*args: tuple[str])(class) allow to remove fields from a class. It can be used to dynamically create schemas based on existing work without creating multiple sources of truth.
- 🛠️ extra parameter should raise a TypeError
- 🛠️ type check for multi-inherited objects
Full Changelog: v0.0.6...v0.0.7
Multiple inheritance
What's Changed
- Multiple inheritance by @6r17 in #5
- 🛠️ Multiple Inheritance should properly render to json-schema
- 🛠️ Set should properly render to json_schema
- 🛠️ Enum should properly render to json_schema
⚠️ required python version bumped to 3.10 because class do not contain__annotation__in 3.9
Full Changelog: v0.0.5...v0.0.6
Customization
What's Changed
- object validation by @6r17 in #3
- 🛠️ "Subscripted generics cannot be used with class and instance checks"
- 🛠️ type_check when used with set or Optional
- 🆕 is_valid method is used on Schema class to allow validation that is dependent on multiple fields
is_value_compatible_with_annotationhas been renamedtype_check- Schema uses
type_checkwhenever in should apply type checking - tests for
type_check(list, set, primitives) schemafunction has been renamedjson_schema- 🆕 pattern attribute on Annotation can be used to define regex validation
- setting a pattern attribute on an Annotation that is not a string or a byte will raise a
SyntaxError - Instantiating an Annotated item that has a pattern with a wrong value raise a
TypeError - pattern attribute is used by
json_schema
Full Changelog: v0.0.4...v0.0.5
Annotation
What's Changed
- Annotation by @6r17 in #2
- Annotation metaclass allows to define additional properties on a
typeused with Schema - Annotation.description is used in the generated json-schema
- Annotation overwrite the new method of a class to do type-check
- Annotation metaclass allows to define additional properties on a
Full Changelog: v0.0.3...v0.0.4
Optional[]
changes:
- Immutable class
- typing.Optional should be used to define nullable attributes. Now raise TypeError when some attributes are missing.
- non optional fields are rendered as required in json-schema
Full Changelog: v0.0.2...v0.0.3
Support
-
This release is meant to explicitly define the python version supported (3.9 +,
madtypesis using typing.get_args et typing.get_origin which were introduced in python 3.9). -
It should also fix the bad long_description on pypi
Full Changelog: v0.0.1...v0.0.2
Hello World !
🎉 Initial release includes :
Schemaclass will raise TypeError at incorrect instantiationSchemaclass will raise TypeError at incorrect setSchemaclass can be used to define an object when using theschemafunction- The
schemafunction will render an annotation as a json-schema - It is possible to use
Annotationclass to define a "description" on the fields which will be used in the rendered schema Schemaclass inherits fromdict; all attributes are set as values of the dictSchemaclass natively repr to it's dict equivalentSchemaclass natively renders trough json.dumps