Like os.getenv but returns an int, or None if the value is missing/malformed.
(key: str)
| 148 | |
| 149 | |
| 150 | def _getenv_int(key: str) -> Optional[int]: |
| 151 | """Like os.getenv but returns an int, or None if the value is missing/malformed.""" |
| 152 | val = os.getenv(key) |
| 153 | if not val: |
| 154 | return None |
| 155 | try: |
| 156 | return int(val) |
| 157 | except ValueError: |
| 158 | return None |
| 159 | |
| 160 | |
| 161 | def _metadata_env() -> dict[str, Any]: |