Parse a float environment variable with proper error handling.
(name: str, default: float)
| 41 | |
| 42 | |
| 43 | def _float_env(name: str, default: float) -> float: |
| 44 | """Parse a float environment variable with proper error handling.""" |
| 45 | value = os.environ.get(name) |
| 46 | if value is None: |
| 47 | return float(default) |
| 48 | |
| 49 | try: |
| 50 | return float(value) |
| 51 | except ValueError as exc: |
| 52 | raise ImproperlyConfigured( |
| 53 | f"Invalid value for {name}: expected float, got {value!r}" |
| 54 | ) from exc |
| 55 | |
| 56 | |
| 57 | #: Worker software/platform information. |
no test coverage detected