I don't like multi-line dictionaries. They're ugly, take up too much space, and distract me from the real logic in the code. I could put it all on one line but then that would break line length convention and be unreadable. In most dictionaries only a few values vary and the rest are constants you type once. This package moves those values into a template you declare once, leaving the call site with just what changes. Nothing crazy, just a small OCD annoyance solved.
Usage
from packd import packd, template
@template
def conn(host: str, port: int, *, timeout: int = 30, ssl: bool = True): ...
packd("conn", "localhost", 5432)
# {"host": "localhost", "port": 5432, "timeout": 30, "ssl": True}
Parameters before the asterisk are passed in, matched by position. Keyword parameters are filled from their defaults, and can be overriden per call.ridden per call:
packd("conn", "localhost", 5432, timeout=5)
Output Keys
Sometimes you need to alias the keys in your dictionary, so you can either convert
them to a case found in the CaseEnum class or alias them individually. You can
do both, the alias always wins.
from packd import CaseEnum
@template(case=CaseEnum.CAMEL, aliases={"content_type": "Content-Type"})
def headers(token: str, *, content_type: str = "application/json", read_timeout: int = 30): ...
packd("headers", "supersecrettoken")
# {"token": "abc", "Content-Type": "application/json", "readTimeout": 30}
Quick Note
The templates register on import, so a template in a file nothing imports won't be found.
Metadata
Release files for packd 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| packd-0.1.2.tar.gz | 53.1 kB | Without provenance | Details for packd-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| packd-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for packd-0.1.2-py3-none-any.whl |
Total release size: 57.1 kB
Release files / packd-0.1.2.tar.gz
| Download URL | packd-0.1.2.tar.gz |
|---|---|
| Size | 53.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
50c0c7bedef99c7a42ca1a97ae3588cc6aa4252e07835271519cc856d1155d64
|
|
BLAKE2b-256 checksum How to use checksums |
466f6a53e2ea79606a2655720422e6a1ad1ca2b1b645beced83d7e268b119bff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / packd-0.1.2-py3-none-any.whl
| Download URL | packd-0.1.2-py3-none-any.whl |
|---|---|
| Size | 4.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fa8b16d4f7e4580841cbda678dc2e9efec087e3a88f5db944607f9d26442ed2c
|
|
BLAKE2b-256 checksum How to use checksums |
90dfa2871a4ed2a0d3750f790cf9058f527af0dea7aed95de08c9248e9c6ae26
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for packd 0.1.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.