Skip to main content

🦆 Quacks

https://img.shields.io/pypi/v/quacks.svg https://img.shields.io/pypi/l/quacks.svg https://img.shields.io/pypi/pyversions/quacks.svg https://github.com/ariebovenberg/quacks/actions/workflows/build.yml/badge.svg https://img.shields.io/readthedocs/quacks.svg https://img.shields.io/badge/code%20style-black-000000.svg

If it walks like a duck and it quacks like a duck, then it must be a duck

Thanks to PEP544, Python now has protocols: a way to define duck typing statically. This library gives you some niceties to make common idioms easier.

Installation

pip install quacks

⚠️ For type checking to work with mypy, you’ll need to enable the plugin in your mypy config file:

[mypy]
plugins = quacks

Features

Easy read-only protocols

Defining read-only protocols is great for encouraging immutability and working with frozen dataclasses. Use the readonly decorator:

from quacks import readonly

@readonly
class User(Protocol):
    id: int
    name: str
    is_premium: bool

Without this decorator, we’d have to write quite a lot of cruft, reducing readability:

class User(Protocol):
    @property
    def id(self) -> int: ...
    @property
    def name(self) -> str: ...
    @property
    def is_premium(self) -> bool: ...

Metadata

Release files for quacks 1.1.1

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

Source distribution (sdist)

Source distribution for quacks 1.1.1
File Size Uploaded
quacks-1.1.1.tar.gz 4.9 kB Details

Built distribution (wheel)

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

Total release size: 11.3 kB

Release files / quacks-1.1.1.tar.gz

Download URL quacks-1.1.1.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
0d53d26645cb5e1f68f963b15c0b388ce1a49a44ec818d26e39e84ed195b1987
BLAKE2b-256 checksum
How to use checksums
52ddfb139a911620070870de7f513f548d72241f37f1b0aff7b099fbb3c3af3b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.15

Release files / quacks-1.1.1-py3-none-any.whl

Download URL quacks-1.1.1-py3-none-any.whl
Size 6.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ef7bfb5d790de7b5807bfd8df2f5f56d1eeb985d6e75c3072dc50b8b93b2971a
BLAKE2b-256 checksum
How to use checksums
06f422956c43a4b469f8b38430f962824eb18c6ea07ece8c6e44fd68a7968e19
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.15

Release history Release notifications | RSS feed

This release

1.1.1 This release

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.2.0

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.1

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