Skip to main content

typeless-dataclasses: use dataclasses without variable annotations

build codecov PyPI black

Have you ever wanted to use dataclasses, but don't like type annotations?

@dataclass
class Data:
    one: Any
    two: Any = 2

... and don't want to resort to any ugly hacks like this one?

@dataclass
class Data:
    one: ...
    two: ... = 2

With the power of typeless-dataclasses, now you can!

@dataclass
@typeless
class Data:
    one = field()
    two = field(default=2)

Compare with attrs:

@attr.s
class Data:
    one = attr.ib()
    two = attr.ib(default=2)

Installing

Install and update using pip:

$ pip install --upgrade typeless-dataclasses

typeless-dataclasses offers a type-annotation-free experience for Python 3.6* and newer, and PyPy.

(On 3.6, you also need to install the dataclasses backport.)

A Simple Example

Using typeless-dataclasses is easy!

Just add @typeless to your class before @dataclass, and use field() as you normally would; field() attributes become instance variables, and all others remain class variables.

>>> from dataclasses import dataclass, field
>>> from typeless_dataclasses import typeless
>>>
>>> @dataclass
... @typeless
... class Data:
...     one = field()
...     two = field(default=2)
...     three = 3
...
>>> Data(1)
Data(one=1, two=2)

Links

Metadata

Release files for typeless-dataclasses 1.0

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

Source distribution (sdist)

Source distribution for typeless-dataclasses 1.0
File Size Uploaded
typeless-dataclasses-1.0.tar.gz 5.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for typeless-dataclasses 1.0
File Interpreter ABI Platform
typeless_dataclasses-1.0-py3-none-any.whl Python 3 none any Details

Total release size: 9.8 kB

Release files / typeless-dataclasses-1.0.tar.gz

Download URL typeless-dataclasses-1.0.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f375f7740d64545a1da4ab569d2d956efe3b701d9fbbb50ec2ed2b9709f614c1
BLAKE2b-256 checksum
How to use checksums
fa4f555aedf44f79c14fe6adcb21c0d65d6e627a90deb16484232dad6a81d219
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.9.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.0

Release files / typeless_dataclasses-1.0-py3-none-any.whl

Download URL typeless_dataclasses-1.0-py3-none-any.whl
Size 4.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a71e86787ee4b043b3f84f9ce9da5d2e0148d37226c513641ed2e5639450d2e7
BLAKE2b-256 checksum
How to use checksums
a2bce249f705a2da3b20b929f8000f6c58a64b50231f8e238366336f12f4e776
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.9.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.0

Release history Release notifications | RSS feed

This release

1.0 This release

2 release files

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