Skip to main content

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.

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.

Metadata

Release files for xattrs 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xattrs 0.0.2
File Size Uploaded Provenance Actions
xattrs-0.0.2.tar.gz 27.9 kB Without provenance Details for xattrs-0.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for xattrs 0.0.2
File Interpreter ABI Platform Actions
xattrs-0.0.2-py3-none-any.whl Python 3 none any Details for xattrs-0.0.2-py3-none-any.whl

Total release size: 58.3 kB

Release files / xattrs-0.0.2.tar.gz

Download URL xattrs-0.0.2.tar.gz
Size 27.9 kB
Tags Source
SHA-256 checksum
How to use checksums
46814678ada06c3827ce542ddf67057487cf63374850ddf4a15e06a6c44a6658
BLAKE2b-256 checksum
How to use checksums
82d185ca97e180c6155d616c0d9e8ae258e5fc8aa9e7d11785f9c4432719c513
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release files / xattrs-0.0.2-py3-none-any.whl

Download URL xattrs-0.0.2-py3-none-any.whl
Size 30.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
60b0158de1a41cf5db3383ba6b7e3957127ff1c6727d809007c463e2c2cddda4
BLAKE2b-256 checksum
How to use checksums
4b6a581722d008ee49a30a444b7220664075ac3d1042994bef131e111961ce6d
Upload date
Uploaded using Trusted Publishing?
What is 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}

Security for xattrs 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page