Lethargy

Latest version: v3.1.0

Safety actively analyzes 714792 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 2 of 2

1.1.0

1.1.0 is very much a quality of life update. In terms of DX, it feels like what 1.0.0 should have been.

Important changes

- Dropped support for Python 3.5 and below
- Added type hints using the typing library
- Use `argv` as a mutable default argument to `Opt.take_flag` and `Opt.take_args`.
This change makes using a namespaced import much more viable.

python
import lethargy

Was:
file1, file2 = lethargy.Opt("files").takes(2).take_args(lethargy.argv)
dprint = lethargy.print_if(lethargy.take_debug(lethargy.argv))

Now:
file1, file2 = lethargy.Opt("files").takes(2).take_args()
dprint = lethargy.print_if(lethargy.take_debug())


- `take_debug` and `take_verbose` will not mutate by default.
- Removed ability to use other (undocumented) values as a "greedy" sentinel
- Use `Opt.converter` for metavar in string representation if it's a type

python
>>> from lethargy import Opt
>>> Will use the converter's name because it's a type
>>> str(Opt("demo").takes(1, int))
'--demo <int>'
>>> Will fall back to "value" because its converter is not a type
>>> str(Opt("test").takes(1, str.split))
'--test <value>'


- `Opt.take_args` keyword arguments (`default`, `raises`, `mut`) must be passed as keywords, cannot be positional.

1.0.0

0.4.0 was already stable and ready for use, 1.0.0 makes some minor changes internally and cleans up some cruft, leading to a slightly improved DX. After not being able to come up with anything useful for a long time, I think that's a good sign that the library has (at least for me) successfully filled its niche.

The only major change is that `Opt.take_args` and `Opt.take_flag` now both take the optional `mut` keyword argument. Setting `mut=False` will not mutate the argument list. This addition removes more boilerplate code and keeps a consistent syntax.

python
>>> import lethargy
>>> lst = ["--name", "test", "example"]
>>> lethargy.Opt("name").takes(2).take_args(lst, mut=False)
['test', 'example']
>>> lst
['--name', 'test', 'example']


Some minor changes include:

- `Opt` also has a more consistent and useful `repr`.

python
>>> import lethargy
>>> lethargy.Opt("name")
<Opt('name') at 0x107e53190>
>>> lethargy.Opt("name").takes(2)
<Opt('name').takes(2) at 0x107dbb790>
>>> lethargy.Opt("name").takes(2, int)
<Opt('name').takes(2, int) at 0x107e53190>


- `Opt.__eq__` compares converters (eg. `Opt().takes(0, int) != Opt().takes(0, list)`)

0.4.0

Lethargy now supports typed arguments (sort of).

Any callable given to `Opt.takes` will be called on each argument. This allows transforming ugly calls like this:

python
from lethargy import Opt, argv

rv = int(Opt("example 1").takes(1).take_args(argv))
a, b = map(int, Opt("example 2").takes(2).take_args(argv))


... into the much more palatable form of:

python
from lethargy import Opt, argv

rv = Opt("example 1").takes(1, int).take_args(argv)
a, b = Opt("example 2").takes(2, int).take_args(argv)


Lethargy now also has `eprint`, which makes printing to stderr much easier.

python
from lethargy import eprint

print("This prints to stdout")
eprint("This prints to stderr")

Page 2 of 2

© 2025 Safety CLI Cybersecurity Inc. All Rights Reserved.