Skip to main content

An eXtensible serializing and deserializing toolkit for Python strucuted classes

Project description

xattrs

PyPI - Version

PyPI - Python Version


xattrs is eXtensible toolkits of your attrs and dataclasses types with sensible default behaviors.

Table of Contents

Motivation

pydantic is a great library to validate and serialize data, but it's not designed to work with attrs or dataclasses as first class support.

attrs is a great library to define classes with declarative and immutable data, but it's not designed to serialize or deserialize instances directly and validate data value by given schema.

attrs incubated dataclasses to define classes without boilerplate in a standard library way. And

...

  • Data Classes are intentionally less powerful than attrs.
  • ...
  • dataclasses can and will be more conservative. We are not bound to any release schedules and we have a clear deprecation policy.

...

-- attrs Documentaion - Why not ...

As I understand, attrs is more powerful and flexible as a third-party library, and has better situation than dataclass to develop and test bleeding-edge ideas and unstable features. And finally, these could also feedback to dataclass.

Unfortunately, while attrs itself is widely adopted, its ecosystem is not as prosperous as pydantic's. Very few libraries are designed to enrich validators, filters or converters for attrs. cattrs attempted to do so, but it hasn't gained the popularity that was expected.

So xattrs is here born to fill the gap between attrs and pydantic, and (try) to provide a better way to work with attrs and dataclasses in a more elegant and powerful way.

[!WARNING]

xattrs is still in early stage of development. Please use it with caution and give feedback to help us to improve it. Thanks!

Try pydantic first if you're looking for a mature and stable solution.

Architecture

xattrs has layered architecture, which is designed to be extensible and customizable.

  • xattrs is the fundamental layer, which provides the core functionalities to serialize and deserialize instances of attrs and dataclasses types.
  • xattrs.schema is the schema layer, which provides the schema functionalities to validate annotated schema for instances of attrs and dataclasses.

Project scope

Let dataclasses or attrs just store declaretive and immutable 'data'.

Goals:

  • Easy to use, easy to extend, easy to customize.
  • Extending upstream project as more as its recommended ways, see also attrs Extending.
  • Pythonic and powerful API for (de)serialization and schema validation
  • Well-tested and well-documented
  • Runable under pyodide (WebAssembly)

Installation

pip install xattrs

How to contribute

The first and the best way to contribute to xattrs is to use it in your project and give feedback on your experience about it both good and bad. You could participate our community by submitting issues or even pull requests, not limited to bugs, but also proposals, documentation, use cases and best practices.

Then you could also try to help us to improve the project by promoting it to your teams, writing blog posts, or even giving a talk in your local community.

If you have did all above, but still thought you could do more. Consider to sponsor the project for long-term maintenance and development.

The most important thing is the community, and we are looking forward to how people enjoy using xattrs and how it could help them to solve their problems.

Development Guide

Major upstream dependencies

  • attrs
  • dataclasses
  • annotated

License

xattrs is distributed under the terms of the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xattrs-0.0.2.tar.gz (27.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xattrs-0.0.2-py3-none-any.whl (30.4 kB view details)

Uploaded Python 3

File details

Details for the file xattrs-0.0.2.tar.gz.

File metadata

  • Download URL: xattrs-0.0.2.tar.gz
  • Upload date:
  • Size: 27.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for xattrs-0.0.2.tar.gz
Algorithm Hash digest
SHA256 46814678ada06c3827ce542ddf67057487cf63374850ddf4a15e06a6c44a6658
MD5 f772f3431725d9bad21aa114d8500b17
BLAKE2b-256 82d185ca97e180c6155d616c0d9e8ae258e5fc8aa9e7d11785f9c4432719c513

See more details on using hashes here.

File details

Details for the file xattrs-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: xattrs-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 30.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for xattrs-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 60b0158de1a41cf5db3383ba6b7e3957127ff1c6727d809007c463e2c2cddda4
MD5 be6ab4b57adaa1c95b4ffd0f0e52eee5
BLAKE2b-256 4b6a581722d008ee49a30a444b7220664075ac3d1042994bef131e111961ce6d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page