typical

Typical: Fast, simple, & correct data-validation using Python 3 typing.

MIT License

Downloads
4.8K
Stars
182
Committers
8

Bot releases are hidden (Show)

typical - Support latest Python and typing-extensions. Latest Release

Published by seandstewart over 1 year ago

What's Changed

New Contributors

Full Changelog: https://github.com/seandstewart/typical/compare/v2.8.0...v2.8.1

typical - v2.8.0

Published by seandstewart almost 3 years ago

What's Changed

Full Changelog: https://github.com/seandstewart/typical/compare/v2.7.11...v2.8.0

typical - v2.7.11

Published by seandstewart almost 3 years ago

What's Changed

  • CPython 3.9.8+ and 3.10.1+ have new logic for type resolution of ForwardRefs which caused a regression in our runtime type analysis. This change adds handling for this new logic.

Full Changelog: https://github.com/seandstewart/typical/compare/v2.7.10...v2.7.11

typical - Fix support for Optional Enums

Published by seandstewart almost 3 years ago

This release fixes a regression in our serializer factory which failed to account for optional/nullable enum types when dumping to a primitive, leading to an AttributeError when attempting to access the enum value.

typical - Improved support for Decimal types

Published by seandstewart almost 3 years ago

What's Changed

New Contributors

Full Changelog: https://github.com/seandstewart/typical/compare/v2.7.8...v2.7.9

typical - Treat `sqlite3.Row` objects as a Mapping type

Published by seandstewart almost 3 years ago

sqlite3.Row objects are C extension types which meet the contract for a mapping, but do not evaluate as a subclass of the Mapping generic. This change adds them to our list of "mapping-compliant" types.

typical - Fix deserialization of extended Mapping types

Published by seandstewart almost 3 years ago

typical - Fix Translation of a NamedTuple to another User Class

Published by seandstewart almost 3 years ago

NamedTuple objects were improperly treated as a simple builtin subtype when coercing user-defined types, which resulted in unexpected behavior. This fixes deserialization logic to use the standard translator protocol for named tuples.

typical - Fix Recursion Error for Derived Classes of `@typic.klass`

Published by seandstewart about 3 years ago

Derived classes of a typic.klass object were improperly recognized as a simple Iterable.

This caused a recursion error when attempting to serialize these objects, since the __iter__ magic method relies upon the iterator factory, but the iterator factory simply called the __iter__ magic method.

Resolves #185

typical - Add support for nested Literal types within Unions

Published by seandstewart about 3 years ago

Fixes

  • #183

Misc

  • Expose always param in the @typic.al decorator.
typical - Improved Support for Constrained and Extended Types

Published by seandstewart about 3 years ago

Fixes:

  • Support collections.deque as Array constraint (resolves #181)
  • Fix union constraints generation on stable py3.10 release.

Misc:

  • Extend DSN support for sqlite urls.
typical - Fix Regression with Nested Containers

Published by seandstewart about 3 years ago

Fixes

  • Nested mappings with exactly two keys could be improperly deserialized (#179)
  • Early return with stdlib get_tojson meant we weren't properly bootstrapping docs.

Improvements

  • asyncpg.Record objects are now recognized as a Mapping type.
typical - Add native support for orjson

Published by seandstewart about 3 years ago

Enhancements

  • typical will now default to orjson for json serialization and deserialization if it is installed. This provides up to 3X performance boost, but has different behavior and output than ujson or stdlib json.
  • Callable class instances are now treated as function types when wrapped (thank you @xbanke, #173)

Fixes

  • Expose the always parameter to typic.klass, since we are raising warnings about its usage (#177)
typical - Optimize Signature Binding and Other Improvements

Published by seandstewart about 3 years ago

Features

  • Wrapped routines and frozen dataclasses now coerce inputs up to 10x faster than before (on-par with wrapped classes or bound protocols) (#175).
  • More descriptive and correct type-hints for the public API.
  • Type-hinting with an abstract base class (ABC) will now result in validation against that type rather than coercion (#170)

Fixes

  • Resolves issue where we'd sometimes fail to clean up the repr of subscripted generics (#170)
  • Resolves issue where we failed to locate the correct target type for a value within a Union of overlapping types (#170)
  • Resolves issue where we'd iterate over the fields of a non-iterable, primitive type when coercing to a collection, rather than raise a TypeError as expected (#174).
typical - Add typing-extensions to required dependencies

Published by seandstewart about 3 years ago

typical - Improve Union-type Determinism

Published by seandstewart about 3 years ago

Fixes

  • Add intelligent instance-checks for unions (resolves #167)
  • Make field.default positional (resolves #168)
  • Add __version__ to typic.__init__ and add bumpver to manage multiple versions (resolves #168)
typical - Add Support for pandas in Union Types

Published by seandstewart about 3 years ago

Fixes

  • This release resolves an issue when building serializers for Unions of pandas collection types (e.g., DataFrame, Series) which prevented proper compilation (#166)

Changes

  • Tagged Unions must be tagged with "public" fields (e.g., no fields starting with _ are considered).
typical - Fix Regression with Dynamic Serialization

Published by seandstewart about 3 years ago

Fixes

  • Fixes dynamic evaluation of serializers for unknown types within containers.
typical - Support for Generic Unions

Published by seandstewart about 3 years ago

Features

  • Support un-tagged, "Generic" Unions (e.g., Union[int, str]) (#19, docs)
  • Basic support for Callable types (#159)

Misc

  • Re-worked handler dispatch in deserializer builder.
  • More idiomatic implementation of delayed SerdeProtocols
typical - Python3.10 Compatibility

Published by seandstewart about 3 years ago

Features

  • This release adds support for Python @ 3.10.0rc1 (#162)

Bugfixes

  • Fix resolution of env-var aliases.
  • Use lazy iterator factory when we can't guess the type.
Package Rankings
Top 5.6% on Pypi.org
Top 38.31% on Conda-forge.org
Badges
Extracted from project README's
image image image image Test & Lint Coverage Code style: black Netlify Status