Install & Compatibility
Where this runs
tested against v0.5.0.post0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.522s · 18.6MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 1.7s · import 0.456s · 19MB
17MB installed
● package 17MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Argument
✓ from dargs import Argument
The main class for defining arguments.
normalize
✓ from dargs import normalize
Normalize input dictionary against argument definitions.
dedent
✓ from dargs import dedent
Remove leading whitespace from multi-line argument documentation.
Variant
✓ from dargs import Variant
Define variant arguments (e.g., different model types).
Basic usage of dargs: define arguments with variants, then normalize user input.
from dargs import Argument, Variant, normalize
# Define arguments
arg1 = Argument("learning_rate", float, default=0.001)
arg2 = Argument("layers", list, default=[128, 64])
# Define a variant
variant = Variant("backend", [
Argument("tensorflow", dict, [
Argument("device", str, default="GPU")
]),
Argument("pytorch", dict, [
Argument("device", str, default="CPU")
])
])
# Compile arguments
args = [arg1, arg2, variant]
# Example user input
user_input = {
"learning_rate": 0.01,
"layers": [256, 128],
"backend": {
"tensorflow": {"device": "TPU"}
}
}
# Normalize (validate and apply defaults)
try:
normalized = normalize(args, user_input)
print("Normalized config:", normalized)
except Exception as e:
print("Error:", e)
Errors
Common errors & fixes
dargs.exceptions.DargsError: The argument 'X' is not defined.
User input contains a key not defined in the argument specification.
fixRemove the extra key or add it to the argument list using Argument(...).
dargs.exceptions.DargsError: The variant choice 'Y' is invalid.
The value for a variant field does not match any of the defined variant choices.
fixCheck the variant choices and provide a valid one; e.g., for backend, use 'tensorflow' or 'pytorch'.
dargs.exceptions.DargsError: Expected type 'int' but got 'str'.
A field value has a mismatched type compared to the Argument's dtype.
fixEnsure the user input conforms to the expected types, or use a custom dtype validator.
Upgrade
Version history
0.5.0.post0latest on PyPI · released Feb 24, 2026
Audit
Dependencies
No dependency data recorded yet.