Skip to content

Releases: 6r17/madtypes

v0.0.9

08 Jun 08:50
c8f902c

Choose a tag to compare

What's Changed

  • 🛠️ list and set usage @6r17 in #10

Full Changelog: v0.0.8...v0.0.9

Refactor

04 Jun 13:00
c5a9953

Choose a tag to compare

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
    • 💢 Annotation is renamed MadType
    • 🤓 MadType support for dict.
    • ⚠️ drop Immutable since it's a poor proposal.
    • ⚠️ drop Schema in 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

01 Jun 09:12
6c34ef4

Choose a tag to compare

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

31 May 12:15
9fe0c55

Choose a tag to compare

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

30 May 13:30
d9fdbb8

Choose a tag to compare

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_annotation has been renamed type_check
    • Schema uses type_check whenever in should apply type checking
    • tests for type_check (list, set, primitives)
    • schema function has been renamed json_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

29 May 17:35
e83e2ab

Choose a tag to compare

What's Changed

  • Annotation by @6r17 in #2
    • Annotation metaclass allows to define additional properties on a type used with Schema
    • Annotation.description is used in the generated json-schema
    • Annotation overwrite the new method of a class to do type-check

Full Changelog: v0.0.3...v0.0.4

Optional[]

28 May 09:21
c095893

Choose a tag to compare

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

27 May 09:18
3791b12

Choose a tag to compare

  • This release is meant to explicitly define the python version supported (3.9 +, madtypes is 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 !

27 May 00:38
8d9d209

Choose a tag to compare

🎉 Initial release includes :

  • Schema class will raise TypeError at incorrect instantiation
  • Schema class will raise TypeError at incorrect set
  • Schema class can be used to define an object when using the schema function
  • The schema function will render an annotation as a json-schema
  • It is possible to use Annotation class to define a "description" on the fields which will be used in the rendered schema
  • Schema class inherits from dict ; all attributes are set as values of the dict
  • Schema class natively repr to it's dict equivalent
  • Schema class natively renders trough json.dumps