A Lombok-inspired boilerplate-elimination library for Python.
Project description
inito
A Lombok-inspired boilerplate-elimination library for Python. inito
generates constructors, repr, equality/hashing, accessors, and fluent
builders once at class-decoration time — never at instance construction or
attribute-access time — so the generated classes perform like handwritten
ones. Zero runtime dependencies.
Install
pip install inito
or
uv add inito
Quick start
from inito import Data
@Data
class User:
name: str
age: int = 0
user = User("Ada", age=30)
print(user) # User(name='Ada', age=30)
print(user.get_name()) # Ada
user.set_age(31)
@Data also accepts options:
from inito import Data
@Data(frozen=True)
class Point:
x: int
y: int
@builder generates a fluent, chainable builder, and composes with
@dataclass:
from dataclasses import dataclass
from inito import builder
@builder(to_builder=True)
@dataclass
class Request:
prompt: str
temperature: float = 0.7
request = Request.builder().prompt("hello").build()
revised = request.to_builder().temperature(0.9).build()
Status
Implemented today: @Data (constructor, __repr__, __eq__, __hash__,
getters, setters), @Getter (getters only), @Setter (setters only),
@NoArgsConstructor (no-argument constructor using field defaults),
@AllArgsConstructor (constructor only, every field),
@RequiredArgsConstructor (constructor only accepting required fields),
@Builder/builder (fluent builder, to_builder=True support),
@ToString (__repr__ only — pairs well with @Builder for a readable
repr without pulling in @Data's constructor/eq/hash/accessors), and
@EqualsAndHashCode (__eq__/__hash__ only).
All of inito.md's Initial Features (v1) are now implemented. See
docs/performance.md for benchmarks against
handwritten classes, dataclasses, and attrs. See TASKS.md
for what's left: docs, CI hardening, and release.
Known limitation: static type checkers don't see generated members yet
Every generated member (get_x, set_x, .builder(), .to_builder(), the
generated constructor's parameters, ...) is attached to your class via
setattr at decoration time — real attributes at runtime, but invisible to
mypy/pyright today, since neither tool has a plugin for inito yet. Your
code will run correctly; mypy --strict/pyright will flag those accesses
as unknown attributes in the meantime. attrs and Pydantic hit the same
problem and solved it with dedicated mypy plugins — that's tracked as a
future initiative (see TASKS.md Phase 17), not required for this release.
Known limitations: frozen dataclasses and self-referential fields
Stacking any inito constructor-generating decorator (@Data, @Builder,
@AllArgsConstructor, ...) with @dataclass(frozen=True) — in either
order — raises dataclasses.FrozenInstanceError. This is expected, not a
bug: the generated __init__/build() assign fields with plain
self.x = value, which correctly respects the frozen class's blocking
__setattr__ rather than silently bypassing the immutability you asked
for. If you want inito's own frozen-style behavior, use @Data(frozen=True)
(which just omits setters) instead of also stacking @dataclass(frozen=True).
Self-referential type hints (e.g. a linked-list next: Node) also aren't
supported: inito resolves annotations eagerly, once, at decoration time —
before the class's own name is bound in its module's globals — so a forward
reference to the class currently being decorated can't resolve. Forward
references to any other, already-defined class work normally.
Contributing
See CONTRIBUTING.md.
License
MIT — see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file inito-0.0.1b0.tar.gz.
File metadata
- Download URL: inito-0.0.1b0.tar.gz
- Upload date:
- Size: 46.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f8eb5f19e94cb5065460b431099632451e40f6417f68c460c295d15df26e6508
|
|
| MD5 |
b1b689169d0163030a82ee79f5d3637e
|
|
| BLAKE2b-256 |
06caff86a919fd80ac51140abaffdc0919468e2a60d5ca497743adcbb775a1fc
|
Provenance
The following attestation bundles were made for inito-0.0.1b0.tar.gz:
Publisher:
release.yml on swtnk/inito
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
inito-0.0.1b0.tar.gz -
Subject digest:
f8eb5f19e94cb5065460b431099632451e40f6417f68c460c295d15df26e6508 - Sigstore transparency entry: 2038932931
- Sigstore integration time:
-
Permalink:
swtnk/inito@1c0066ca37e26340a716f441bfadb9154ab6caf4 -
Branch / Tag:
refs/tags/v0.0.1-beta - Owner: https://github.com/swtnk
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1c0066ca37e26340a716f441bfadb9154ab6caf4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file inito-0.0.1b0-py3-none-any.whl.
File metadata
- Download URL: inito-0.0.1b0-py3-none-any.whl
- Upload date:
- Size: 25.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6911cc803122b6d5158f0713799521e93c57bf676044de5dda2dbce706453417
|
|
| MD5 |
9404cb8e2683c1f50919f30284c3a7ba
|
|
| BLAKE2b-256 |
ce53bd4b1b8143e48be617f66ccc4dd75e00de1ac492f56bf6fb1be0a352f7c4
|
Provenance
The following attestation bundles were made for inito-0.0.1b0-py3-none-any.whl:
Publisher:
release.yml on swtnk/inito
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
inito-0.0.1b0-py3-none-any.whl -
Subject digest:
6911cc803122b6d5158f0713799521e93c57bf676044de5dda2dbce706453417 - Sigstore transparency entry: 2038932973
- Sigstore integration time:
-
Permalink:
swtnk/inito@1c0066ca37e26340a716f441bfadb9154ab6caf4 -
Branch / Tag:
refs/tags/v0.0.1-beta - Owner: https://github.com/swtnk
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1c0066ca37e26340a716f441bfadb9154ab6caf4 -
Trigger Event:
push
-
Statement type: