You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

envier

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

envier - pypi Package Compare versions

Comparing version
0.1.0
to
0.2.0
+2
-1
.github/workflows/main.yml

@@ -70,2 +70,3 @@ name: CI

python3.9 -m pip install riot
riot -v run --python=${{ matrix.python-version }} test
riot -v run --python=${{ matrix.python-version }} smoke-test
riot -v run --python=${{ matrix.python-version }} tests
Metadata-Version: 2.1
Name: envier
Version: 0.1.0
Version: 0.2.0
Summary: Python application configuration via the environment

@@ -5,0 +5,0 @@ Home-page: https://github.com/DataDog/envier

[:python_version < "3.5"]
typing
[mypy]
mypy

@@ -51,2 +51,3 @@ import os

parser=None, # type: Optional[Callable[[str], T]]
validator=None, # type: Optional[Callable[[T], None]]
map=None, # type: Optional[MapType]

@@ -67,2 +68,3 @@ default=NoDefault, # type: Union[T, NoDefaultType]

self.parser = parser
self.validator = validator
self.map = map

@@ -72,3 +74,3 @@ self.default = default

def __call__(self, env, prefix):
def _retrieve(self, env, prefix):
# type: (Env, str) -> T

@@ -148,3 +150,12 @@ source = env.source

def __call__(self, env, prefix):
# type: (Env, str) -> T
value = self._retrieve(env, prefix)
if self.validator is not None:
self.validator(value)
return value
class DerivedVariable(Generic[T]):

@@ -241,2 +252,3 @@ def __init__(self, type, derivation):

parser=None, # type: Optional[Callable[[str], T]]
validator=None, # type: Optional[Callable[[T], None]]
map=None, # type: Optional[MapType]

@@ -247,3 +259,3 @@ default=NoDefault, # type: Union[T, NoDefaultType]

# type: (...) -> EnvVariable[T]
return EnvVariable(type, name, parser, map, default, deprecations)
return EnvVariable(type, name, parser, validator, map, default, deprecations)

@@ -256,2 +268,3 @@ @classmethod

parser=None, # type: Optional[Callable[[str], T]]
validator=None, # type: Optional[Callable[[T], None]]
map=None, # type: Optional[MapType]

@@ -262,3 +275,3 @@ default=NoDefault, # type: Union[T, NoDefaultType]

# type: (...) -> EnvVariable[T]
return EnvVariable(type, name, parser, map, default, deprecations)
return EnvVariable(type, name, parser, validator, map, default, deprecations)

@@ -303,2 +316,4 @@ @classmethod

return None
# Pick only the attributes that define variables.

@@ -305,0 +320,0 @@ to_include = {

Metadata-Version: 2.1
Name: envier
Version: 0.1.0
Version: 0.2.0
Summary: Python application configuration via the environment

@@ -5,0 +5,0 @@ Home-page: https://github.com/DataDog/envier

@@ -24,2 +24,7 @@ from ast import Sub

Venv(
name="smoke-test",
command="python -c 'import envier'",
pys=SUPPORTED_PYTHON_VERSIONS,
),
Venv(
name="black",

@@ -26,0 +31,0 @@ pkgs={"black": latest},

@@ -30,3 +30,3 @@ from setuptools import find_packages

python_requires=">=2.7",
install_requires=[],
install_requires=["typing; python_version<'3.5'"],
extras_require={"mypy": ["mypy"]},

@@ -33,0 +33,0 @@ setup_requires=["setuptools_scm"],

@@ -246,3 +246,7 @@ from typing import Optional

# Check that we are not including configuration elsewhere
with pytest.raises(AttributeError):
GlobalConfig().host
@pytest.mark.parametrize(

@@ -315,1 +319,27 @@ "map,expected",

assert DictConfig().foo is value
@pytest.mark.parametrize(
"value,exc",
[
(0, None),
(512, None),
(-1, ValueError),
(513, ValueError),
],
)
def test_env_validator(monkeypatch, value, exc):
monkeypatch.setenv("FOO", str(value))
class Config(Env):
def validate(value):
if not (0 <= value <= 512):
raise ValueError("Value must be between 0 and 512")
foo = Env.var(int, "FOO", validator=validate)
if exc is not None:
with pytest.raises(exc):
Config()
else:
assert Config().foo == value