sleazy
A tiny utility to build CLI tools from Python TypedDict schemas.
Define your parameters with type hints (and Annotated for positionals), then call parse() to get a typed dict and
stringify() to turn it back into args.
Installation
uv pip install sleazy
Example CLI
from typing import Annotated, Literal, TypedDict
from sleazy import parse, stringify
class AppConfig(TypedDict):
# 1) Required positional (exactly one string)
input_file: Annotated[str, 1]
# 2) Optional positional (zero or more strings)
tags: Annotated[str, "*"]
# 3) Optional keyword args
output: str # string
verbose: bool # flag
retries: int # integer
mode: Literal["auto", "manual"] # choice via Literal or enum
if __name__ == "__main__":
# parse() returns a dict matching AppConfig
args = parse(AppConfig) # python example.py data.txt tag1 tag2 --output out.txt --verbose --retries 5 --mode auto
print(args)
# {
# 'input_file': 'data.txt',
# 'tags': ['tag1', 'tag2'],
# 'output': 'out.txt',
# 'verbose': True,
# 'retries': 5,
# 'mode': 'auto'
# }
# stringify back to CLI args, using AppConfig to keep positionals first
print(stringify(args, AppConfig))
# [
# 'data.txt',
# 'tag1', 'tag2',
# '--output', 'out.txt',
# '--verbose',
# '--retries', '5',
# '--mode', 'auto'
# ]
# Without the TypedDict, stringify treats everything as flags
print(stringify(args))
# [
# '--input-file', 'data.txt',
# '--tags', 'tag1', '--tags', 'tag2',
# '--output', 'out.txt',
# '--verbose',
# '--retries', '5',
# '--mode', 'auto'
# ]
Notes
- Positionals are marked via
Annotated[type, count](1,?,*,+, or exact integer). - All other fields become
--field-nameflags by default. - It's useful to pass your
TypedDicttype tostringify()so it knows which fields are positional (and their order). Without it, everything is emitted as a keyword flag.
Metadata
Release files for sleazy 0.2.0
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 |
|---|---|---|---|---|
| sleazy-0.2.0.tar.gz | 42.5 kB | Without provenance | Details for sleazy-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sleazy-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for sleazy-0.2.0-py3-none-any.whl |
Total release size: 46.8 kB
Release files / sleazy-0.2.0.tar.gz
| Download URL | sleazy-0.2.0.tar.gz |
|---|---|
| Size | 42.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7499177079a60a112510416a55d24536808ebc6f4a371ff5aec5cb6675ef98a2
|
|
BLAKE2b-256 checksum How to use checksums |
163e453c16b308d0e95fdc9039ef2e3d76678eef2e0d91045b0e975727a7414d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-httpx/0.28.1
|
Release files / sleazy-0.2.0-py3-none-any.whl
| Download URL | sleazy-0.2.0-py3-none-any.whl |
|---|---|
| Size | 4.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c3a56ee770a80f84b8f4a0398d72f96abe3583cfd31ac1d381cf70f66346d636
|
|
BLAKE2b-256 checksum How to use checksums |
214ee666300efdd52f347c80c595e118fff110650eecc269d27ec3206cd57145
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-httpx/0.28.1
|
Security for sleazy 0.2.0
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.