envbool 0.4.1__tar.gz → 0.4.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- envbool-0.4.2/LICENSE +21 -0
- {envbool-0.4.1 → envbool-0.4.2}/PKG-INFO +13 -11
- {envbool-0.4.1 → envbool-0.4.2}/README.md +11 -10
- {envbool-0.4.1 → envbool-0.4.2}/pyproject.toml +2 -1
- {envbool-0.4.1 → envbool-0.4.2}/pyproject.toml.orig +2 -1
- {envbool-0.4.1 → envbool-0.4.2}/src/envbool/__init__.py +0 -0
- {envbool-0.4.1 → envbool-0.4.2}/src/envbool/__main__.py +0 -0
- {envbool-0.4.1 → envbool-0.4.2}/src/envbool/_cli.py +0 -0
- {envbool-0.4.1 → envbool-0.4.2}/src/envbool/_core.py +0 -0
- {envbool-0.4.1 → envbool-0.4.2}/src/envbool/_defaults.py +0 -0
- {envbool-0.4.1 → envbool-0.4.2}/src/envbool/_env.py +0 -0
- {envbool-0.4.1 → envbool-0.4.2}/src/envbool/exceptions.py +0 -0
- {envbool-0.4.1 → envbool-0.4.2}/src/envbool/py.typed +0 -0
envbool-0.4.2/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Kyle
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: envbool
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.2
|
|
4
4
|
Summary: A small Python library and CLI tool for coercing environment variables (and arbitrary strings) into boolean values.
|
|
5
5
|
Keywords: environment variables,boolean,configuration,env,coerce
|
|
6
6
|
Author: Kyle O'Malley
|
|
7
7
|
Author-email: Kyle O'Malley <j.kyle.omalley@gmail.com>
|
|
8
8
|
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
9
10
|
Classifier: Development Status :: 4 - Beta
|
|
10
11
|
Classifier: Intended Audience :: Developers
|
|
11
12
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
@@ -44,9 +45,9 @@ Reading a boolean out of the environment is the kind of thing every project
|
|
|
44
45
|
reinvents, slightly differently, in slightly buggy ways:
|
|
45
46
|
|
|
46
47
|
```python
|
|
47
|
-
DEBUG
|
|
48
|
+
DEBUG = os.environ.get("DEBUG", "").lower() in ("1", "true", "yes")
|
|
48
49
|
VERBOSE = os.environ.get("VERBOSE", "").lower() in ("1", "true", "yes")
|
|
49
|
-
CACHE
|
|
50
|
+
CACHE = os.environ.get("CACHE", "").lower() in ("1", "true", "yes")
|
|
50
51
|
```
|
|
51
52
|
|
|
52
53
|
`envbool` is that snippet, done once and done properly:
|
|
@@ -54,9 +55,9 @@ CACHE = os.environ.get("CACHE", "").lower() in ("1", "true", "yes")
|
|
|
54
55
|
```python
|
|
55
56
|
from envbool import envbool
|
|
56
57
|
|
|
57
|
-
DEBUG
|
|
58
|
+
DEBUG = envbool("DEBUG")
|
|
58
59
|
VERBOSE = envbool("VERBOSE")
|
|
59
|
-
CACHE
|
|
60
|
+
CACHE = envbool("CACHE")
|
|
60
61
|
```
|
|
61
62
|
|
|
62
63
|
## Features
|
|
@@ -100,8 +101,8 @@ uv add envbool
|
|
|
100
101
|
```python
|
|
101
102
|
from envbool import envbool
|
|
102
103
|
|
|
103
|
-
DEBUG = envbool("DEBUG")
|
|
104
|
-
CACHE = envbool("CACHE", default=True)
|
|
104
|
+
DEBUG = envbool("DEBUG") # False if unset or empty
|
|
105
|
+
CACHE = envbool("CACHE", default=True) # True if unset or empty
|
|
105
106
|
```
|
|
106
107
|
|
|
107
108
|
The built-in truthy values are `true`, `1`, `yes`, `on`; the falsy values are
|
|
@@ -144,8 +145,8 @@ same keyword arguments as `envbool`.
|
|
|
144
145
|
```python
|
|
145
146
|
from envbool import to_bool
|
|
146
147
|
|
|
147
|
-
to_bool("yes")
|
|
148
|
-
to_bool("0")
|
|
148
|
+
to_bool("yes") # True
|
|
149
|
+
to_bool("0") # False
|
|
149
150
|
to_bool("maybe", strict=True) # raises InvalidBoolValueError
|
|
150
151
|
```
|
|
151
152
|
|
|
@@ -284,9 +285,9 @@ from envbool import envbool, InvalidBoolValueError
|
|
|
284
285
|
try:
|
|
285
286
|
result = envbool("MY_VAR", strict=True)
|
|
286
287
|
except InvalidBoolValueError as e:
|
|
287
|
-
print(e.var)
|
|
288
|
+
print(e.var) # "MY_VAR" — env var name, or None when raised from to_bool()
|
|
288
289
|
print(e.value) # "maybe" — the normalized (stripped, lowercased) value
|
|
289
|
-
print(e.truthy)
|
|
290
|
+
print(e.truthy) # frozenset({"true", "1", "yes", "on"}) — effective truthy set
|
|
290
291
|
print(e.falsy) # frozenset({"false", "0", "no", "off"}) — effective falsy set
|
|
291
292
|
```
|
|
292
293
|
|
|
@@ -345,6 +346,7 @@ fixture so overrides don't leak across the suite:
|
|
|
345
346
|
import pytest
|
|
346
347
|
from envbool import reset_defaults
|
|
347
348
|
|
|
349
|
+
|
|
348
350
|
@pytest.fixture(autouse=True)
|
|
349
351
|
def _reset_envbool_defaults():
|
|
350
352
|
yield
|
|
@@ -17,9 +17,9 @@ Reading a boolean out of the environment is the kind of thing every project
|
|
|
17
17
|
reinvents, slightly differently, in slightly buggy ways:
|
|
18
18
|
|
|
19
19
|
```python
|
|
20
|
-
DEBUG
|
|
20
|
+
DEBUG = os.environ.get("DEBUG", "").lower() in ("1", "true", "yes")
|
|
21
21
|
VERBOSE = os.environ.get("VERBOSE", "").lower() in ("1", "true", "yes")
|
|
22
|
-
CACHE
|
|
22
|
+
CACHE = os.environ.get("CACHE", "").lower() in ("1", "true", "yes")
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
`envbool` is that snippet, done once and done properly:
|
|
@@ -27,9 +27,9 @@ CACHE = os.environ.get("CACHE", "").lower() in ("1", "true", "yes")
|
|
|
27
27
|
```python
|
|
28
28
|
from envbool import envbool
|
|
29
29
|
|
|
30
|
-
DEBUG
|
|
30
|
+
DEBUG = envbool("DEBUG")
|
|
31
31
|
VERBOSE = envbool("VERBOSE")
|
|
32
|
-
CACHE
|
|
32
|
+
CACHE = envbool("CACHE")
|
|
33
33
|
```
|
|
34
34
|
|
|
35
35
|
## Features
|
|
@@ -73,8 +73,8 @@ uv add envbool
|
|
|
73
73
|
```python
|
|
74
74
|
from envbool import envbool
|
|
75
75
|
|
|
76
|
-
DEBUG = envbool("DEBUG")
|
|
77
|
-
CACHE = envbool("CACHE", default=True)
|
|
76
|
+
DEBUG = envbool("DEBUG") # False if unset or empty
|
|
77
|
+
CACHE = envbool("CACHE", default=True) # True if unset or empty
|
|
78
78
|
```
|
|
79
79
|
|
|
80
80
|
The built-in truthy values are `true`, `1`, `yes`, `on`; the falsy values are
|
|
@@ -117,8 +117,8 @@ same keyword arguments as `envbool`.
|
|
|
117
117
|
```python
|
|
118
118
|
from envbool import to_bool
|
|
119
119
|
|
|
120
|
-
to_bool("yes")
|
|
121
|
-
to_bool("0")
|
|
120
|
+
to_bool("yes") # True
|
|
121
|
+
to_bool("0") # False
|
|
122
122
|
to_bool("maybe", strict=True) # raises InvalidBoolValueError
|
|
123
123
|
```
|
|
124
124
|
|
|
@@ -257,9 +257,9 @@ from envbool import envbool, InvalidBoolValueError
|
|
|
257
257
|
try:
|
|
258
258
|
result = envbool("MY_VAR", strict=True)
|
|
259
259
|
except InvalidBoolValueError as e:
|
|
260
|
-
print(e.var)
|
|
260
|
+
print(e.var) # "MY_VAR" — env var name, or None when raised from to_bool()
|
|
261
261
|
print(e.value) # "maybe" — the normalized (stripped, lowercased) value
|
|
262
|
-
print(e.truthy)
|
|
262
|
+
print(e.truthy) # frozenset({"true", "1", "yes", "on"}) — effective truthy set
|
|
263
263
|
print(e.falsy) # frozenset({"false", "0", "no", "off"}) — effective falsy set
|
|
264
264
|
```
|
|
265
265
|
|
|
@@ -318,6 +318,7 @@ fixture so overrides don't leak across the suite:
|
|
|
318
318
|
import pytest
|
|
319
319
|
from envbool import reset_defaults
|
|
320
320
|
|
|
321
|
+
|
|
321
322
|
@pytest.fixture(autouse=True)
|
|
322
323
|
def _reset_envbool_defaults():
|
|
323
324
|
yield
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "envbool"
|
|
3
|
-
version = "0.4.
|
|
3
|
+
version = "0.4.2"
|
|
4
4
|
description = "A small Python library and CLI tool for coercing environment variables (and arbitrary strings) into boolean values."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.11"
|
|
7
7
|
license = "MIT"
|
|
8
|
+
license-files = ["LICENSE"]
|
|
8
9
|
keywords = [
|
|
9
10
|
"environment variables",
|
|
10
11
|
"boolean",
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "envbool"
|
|
3
|
-
version = "0.4.
|
|
3
|
+
version = "0.4.2"
|
|
4
4
|
description = "A small Python library and CLI tool for coercing environment variables (and arbitrary strings) into boolean values."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
authors = [{ name = "Kyle O'Malley", email = "j.kyle.omalley@gmail.com" }]
|
|
7
7
|
requires-python = ">=3.11"
|
|
8
8
|
license = "MIT"
|
|
9
|
+
license-files = ["LICENSE"]
|
|
9
10
|
keywords = ["environment variables", "boolean", "configuration", "env", "coerce"]
|
|
10
11
|
dependencies = []
|
|
11
12
|
classifiers = [
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|