mirror of
https://github.com/deepseek-ai/DeepInfer.git
synced 2026-10-26 16:35:05 +00:00
fix: validate boolean environment variables with strict parsing (#218)
This commit is contained in:
1 parent
9bd9cf243f
commit
553741557a
1 file changed
+8
-1
@@ -7,10 +7,17 @@ from datetime import timedelta
|
||||
from typing import Any
|
||||
|
||||
DEFAULT_PREFILL_MAX_SUM_SEQLEN_K = 2**30
|
||||
_FALSE = {"0", "", "false"}
|
||||
_TRUE = {"1", "true"}
|
||||
|
||||
|
||||
def _bool(v: str | None, default: str = "0") -> bool:
|
||||
return (v if v is not None else default) not in ("0", "", "false", "False")
|
||||
value = (v if v is not None else default).lower()
|
||||
if value in _FALSE:
|
||||
return False
|
||||
if value in _TRUE:
|
||||
return True
|
||||
raise ValueError("expected one of '0', '1', 'false', 'true' (case-insensitive)")
|
||||
|
||||
|
||||
def _int(v: str | None, default: int = 0) -> int:
|
||||
|
||||
Reference in new issue
Block a user