refactor: some minor cleanup
This commit is contained in:
parent
307ca38ecc
commit
858d127246
12 changed files with 84 additions and 59 deletions
22
src/utils/env.py
Normal file
22
src/utils/env.py
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import os
|
||||
|
||||
|
||||
def parse_int_env(
|
||||
name: str,
|
||||
default: int,
|
||||
minimum: int,
|
||||
maximum: int,
|
||||
) -> int:
|
||||
raw = os.environ.get(name)
|
||||
if raw is None:
|
||||
return default
|
||||
|
||||
try:
|
||||
value = int(raw)
|
||||
except ValueError:
|
||||
return default
|
||||
|
||||
if value < minimum or value > maximum:
|
||||
return default
|
||||
|
||||
return value
|
||||
Loading…
Add table
Add a link
Reference in a new issue