Metadata-Version: 2.5
Name: boolish
Version: 0.1.0
Summary: Typed, dependency-free replacement for the strtobool removed from the standard library
Project-URL: Homepage, https://lianes8studio.com
Project-URL: Repository, https://github.com/JaviLianes8/boolish
Project-URL: Issues, https://github.com/JaviLianes8/boolish/issues
Project-URL: Changelog, https://github.com/JaviLianes8/boolish/blob/main/CHANGELOG.md
Project-URL: LinkedIn, https://www.linkedin.com/in/jlianes/
Project-URL: Funding, https://buymeacoffee.com/jlianesglrs
Author-email: Javier Lianes <javier@lianes8studio.com>
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Typing :: Typed
Requires-Python: >=3.10
Provides-Extra: dev
Requires-Dist: build; extra == 'dev'
Requires-Dist: mypy; extra == 'dev'
Requires-Dist: pytest; extra == 'dev'
Requires-Dist: ruff; extra == 'dev'
Requires-Dist: twine; extra == 'dev'
Description-Content-Type: text/markdown

# boolish

Parse a string into a boolean. A typed, dependency-free stand-in for
`distutils.util.strtobool`, which was removed from the standard library in Python 3.12.

## Install

```
pip install boolish
```

## Usage

```python
from boolish import strtobool

strtobool("yes")     # True
strtobool("Off")     # False
strtobool("  1 ")    # True  (space and case are ignored)
strtobool("maybe")   # ValueError
```

Give a default to get it back instead of an error:

```python
strtobool("maybe", False)   # False
```

Read a flag straight from the environment. A missing variable falls back to the
default; a set-but-nonsense value raises, so a misconfigured flag fails loudly:

```python
from boolish import getenv_bool

getenv_bool("ENABLE_CACHE", False)
```

Bring your own vocabulary:

```python
from boolish import BoolRules, strtobool

spanish = BoolRules(true={"sí", "verdadero"}, false={"no", "falso"})
strtobool("SÍ", rules=spanish)   # True
```

## Why

The standard library's `strtobool` was the quiet default for reading boolean flags and
environment variables. It was deprecated in 3.10 and removed in 3.12, and the dedicated
packages that filled the gap have gone unmaintained for years. This is the same idea,
kept small: real `bool` results, type hints, no dependencies, and the environment helper
most projects ended up writing by hand.

## License

MIT — see [LICENSE](LICENSE).

## Links

- Website — https://lianes8studio.com
- GitHub — https://github.com/JaviLianes8
- LinkedIn — https://www.linkedin.com/in/jlianes/
