NanoArgs
A tiny, opinionated configuration loader and CLI framework built around Pydantic models.
Features
- YAML Configuration Loading — load and merge multiple files with left-to-right precedence
- Smart Imports —
!importloads one file, path resolved relative to the importing file - Composable Merging —
!mergedeep-merges imports and inline mappings left to right - Runtime Overrides — JSONPath-like syntax via
--override - Pydantic Validation — automatic validation and type coercion
- Schema Generation —
--print-schemarenders a formatted JSON schema;--print-configdumps the merged result - Rich CLI Interface — styled help, errors, and schema output via Rich
- Subcommands — multi-command CLIs via
Nested; each command owns its own config model - Type Safety — pyright strict, modern Python type hints
Installation
pip install git+https://github.com/cusp-ai-oss/nanoargs.git
Requires Python 3.10+. Dependencies: lark, pydantic, pyyaml, rich, rich-argparse.
Quick Start
from pydantic import BaseModel
from nanoargs import NanoArgs
class Config(BaseModel):
mode: str = "train"
batch_size: int = 32
learning_rate: float = 0.001
config = NanoArgs(Config).parse()
python app.py config.yaml # load a YAML file
python app.py base.yaml exp.yaml # merge multiple files
python app.py config.yaml --override '$.batch_size=128' # JSONPath override
echo 'batch_size: 128' | python app.py - # read from stdin
python app.py --print-schema # inspect the schema
python app.py config.yaml --print-config # inspect merged result
Subcommands
Use Nested to define multi-command CLIs. Fields typed as T | None = None become subcommands:
from nanoargs import NanoArgs, Nested
class TrainConfig(BaseModel):
lr: float = 0.001
epochs: int = 10
class EvalConfig(BaseModel):
checkpoint: str
class CLI(Nested):
verbose: bool = False # pre-command parent field
train: TrainConfig | None = None
evaluate: EvalConfig | None = None
result = NanoArgs(CLI).parse()
python app.py train config.yaml --override '$.lr=0.01'
python app.py --override '$.verbose=true' evaluate config.yaml
python app.py --help # lists available commands
python app.py train --print-schema # schema for a specific command
Nested composes naturally — a field whose type is itself Nested creates a sub-group (app data preprocess config.yaml).
See the Subcommands guide for full details.
Documentation
- Getting Started — full walkthrough
- Configuration Guide — import system, merge rules, override syntax, CLI flags
- Subcommands —
Nestedpatterns, parent fields, multi-level nesting - Path Syntax — JSONPath-like grammar reference
- API Reference
- Changelog
Gotchas
- YAML booleans in config files:
yes,no,on,offare booleans in YAML. Quote them for strings:"yes". This does not affect--overridevalues. - List merging: config file merging replaces lists entirely — it does not append.
- Hyphenated keys:
--overridepaths require bracket syntax:--override '$["learning-rate"]=0.001'. - Negative array indices:
$[-1]works Python-style (last element). Negative slice bounds are also supported:$[-3:],$[:-1]. - Bracket notation quotes: both
$["key"]and$['key']are supported. --print-configwithout config files: prints Pydantic-validated defaults and exits.- Unknown fields: overriding a path that doesn't match any model field is silently ignored by Pydantic.
- Auto-vivification:
$.a.b.c=1creates intermediate dicts for missing keys orNonevalues. @fileresolution: from the CLI,@fileresolves relative to the working directory; inside YAML (!override), relative to the YAML file. Use@@to escape a literal@.
License
Apache 2.0
Metadata
Release files for nanoargs 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 |
|---|---|---|---|---|
| nanoargs-0.2.0.tar.gz | 109.8 kB | With provenance | Details for nanoargs-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nanoargs-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for nanoargs-0.2.0-py3-none-any.whl |
Total release size: 131.9 kB
Release files / nanoargs-0.2.0.tar.gz
| Download URL | nanoargs-0.2.0.tar.gz |
|---|---|
| Size | 109.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
437a70d721bd5997169fd4d206ee1e2151e2086c069c5f912bcac5a66bba6636
|
|
BLAKE2b-256 checksum How to use checksums |
e0189a20e9f22e302ee37b339bf07145608459ec5486115961515de844debb54
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 23, 2026.
Transparency logRelease files / nanoargs-0.2.0-py3-none-any.whl
| Download URL | nanoargs-0.2.0-py3-none-any.whl |
|---|---|
| Size | 22.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
027cb5bd8efbe750f5437a88191777550dda29e91f23e59b29811c0a7e344201
|
|
BLAKE2b-256 checksum How to use checksums |
c29bb83c84cd6d0c3d58351cd41935316eda416fd9da163165f4ca76b658b0b6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 23, 2026.
Transparency logSecurity for nanoargs 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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for nanoargs-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 23, 2026.
Transparency logA 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.