Metadata-Version: 2.5
Name: packd
Version: 0.1.0
Summary: Collapse a dictionary construction into a single call
Author: Gabe Kutner
License-File: LICENSE
Requires-Python: >=3.9
Provides-Extra: dev
Requires-Dist: mypy; extra == 'dev'
Requires-Dist: pre-commit; extra == 'dev'
Requires-Dist: pytest; extra == 'dev'
Requires-Dist: ruff; extra == 'dev'
Description-Content-Type: text/markdown

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

```python
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:

```python
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.

```python
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.
