1010import sys
1111from dataclasses import dataclass
1212from pathlib import Path
13- from typing import Optional
1413
1514
1615@dataclass
1716class Environment :
1817 """Information about the current execution environment."""
1918
2019 os_type : str # "linux", "darwin", "windows"
21- linux_distro : Optional [ str ] = None # "ubuntu", "debian", "rhel", "fedora", "alpine", "arch", etc.
22- linux_distro_version : Optional [ str ] = None # e.g., "22.04", "11", "9"
23- cloud_provider : Optional [ str ] = None # "aws", "gcp", "azure"
20+ linux_distro : str | None = None # "ubuntu", "debian", "rhel", "fedora", "alpine", "arch", etc.
21+ linux_distro_version : str | None = None # e.g., "22.04", "11", "9"
22+ cloud_provider : str | None = None # "aws", "gcp", "azure"
2423 is_lambda : bool = False # AWS Lambda
2524 is_cloud_function : bool = False # GCP Cloud Functions or Azure Functions
2625 is_docker : bool = False
2726 is_kubernetes : bool = False
2827 is_wsl : bool = False # Windows Subsystem for Linux
2928 is_ci : bool = False
30- ci_platform : Optional [ str ] = None # "github", "gitlab", "circleci", "jenkins", etc.
29+ ci_platform : str | None = None # "github", "gitlab", "circleci", "jenkins", etc.
3130 is_venv : bool = False
3231 is_conda : bool = False
3332 has_sudo : bool = False # Best guess if user has sudo access
3433
3534
36- def _read_probe_file (path : Path ) -> Optional [ str ] :
35+ def _read_probe_file (path : Path ) -> str | None :
3736 """
3837 Read an optional environment probe file.
3938
@@ -53,7 +52,7 @@ def _read_probe_file(path: Path) -> Optional[str]:
5352 return None
5453
5554
56- def _detect_linux_distro () -> tuple [Optional [ str ], Optional [ str ] ]:
55+ def _detect_linux_distro () -> tuple [str | None , str | None ]:
5756 """
5857 Detect Linux distribution and version.
5958
@@ -122,7 +121,7 @@ def _detect_linux_distro() -> tuple[Optional[str], Optional[str]]:
122121 return None , None
123122
124123
125- def _detect_cloud_provider () -> Optional [ str ] :
124+ def _detect_cloud_provider () -> str | None :
126125 """
127126 Detect if running on a cloud provider.
128127
@@ -213,7 +212,7 @@ def _detect_wsl() -> bool:
213212 return Path ("/mnt/c" ).exists () and Path ("/proc/version" ).exists ()
214213
215214
216- def _detect_ci () -> tuple [bool , Optional [ str ] ]:
215+ def _detect_ci () -> tuple [bool , str | None ]:
217216 """
218217 Detect if running in a CI/CD environment.
219218
0 commit comments