From c542968f635fead96abc21bfb1fde5ce6fc3525a Mon Sep 17 00:00:00 2001 From: Jirka B Date: Wed, 13 Nov 2024 21:10:08 +0100 Subject: [PATCH] apply fixes --- src/lightning/fabric/accelerators/cpu.py | 4 ++-- src/lightning/pytorch/accelerators/cpu.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/lightning/fabric/accelerators/cpu.py b/src/lightning/fabric/accelerators/cpu.py index 0334210ecd..2997d1ada3 100644 --- a/src/lightning/fabric/accelerators/cpu.py +++ b/src/lightning/fabric/accelerators/cpu.py @@ -11,7 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -from typing import List, Union +from typing import Union import torch from typing_extensions import override @@ -45,7 +45,7 @@ class CPUAccelerator(Accelerator): @staticmethod @override - def get_parallel_devices(devices: Union[int, str]) -> List[torch.device]: + def get_parallel_devices(devices: Union[int, str]) -> list[torch.device]: """Gets parallel devices for the Accelerator.""" devices = _parse_cpu_cores(devices) return [torch.device("cpu")] * devices diff --git a/src/lightning/pytorch/accelerators/cpu.py b/src/lightning/pytorch/accelerators/cpu.py index a85a959ab6..525071cbb3 100644 --- a/src/lightning/pytorch/accelerators/cpu.py +++ b/src/lightning/pytorch/accelerators/cpu.py @@ -11,7 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -from typing import Any, Dict, List, Union +from typing import Any, Union import torch from lightning_utilities.core.imports import RequirementCache @@ -38,7 +38,7 @@ class CPUAccelerator(Accelerator): raise MisconfigurationException(f"Device should be CPU, got {device} instead.") @override - def get_device_stats(self, device: _DEVICE) -> Dict[str, Any]: + def get_device_stats(self, device: _DEVICE) -> dict[str, Any]: """Get CPU stats from ``psutil`` package.""" return get_cpu_stats() @@ -54,7 +54,7 @@ class CPUAccelerator(Accelerator): @staticmethod @override - def get_parallel_devices(devices: Union[int, str]) -> List[torch.device]: + def get_parallel_devices(devices: Union[int, str]) -> list[torch.device]: """Gets parallel devices for the Accelerator.""" devices = _parse_cpu_cores(devices) return [torch.device("cpu")] * devices @@ -89,7 +89,7 @@ _CPU_SWAP_PERCENT = "cpu_swap_percent" _PSUTIL_AVAILABLE = RequirementCache("psutil") -def get_cpu_stats() -> Dict[str, float]: +def get_cpu_stats() -> dict[str, float]: if not _PSUTIL_AVAILABLE: raise ModuleNotFoundError( f"Fetching CPU device stats requires `psutil` to be installed. {str(_PSUTIL_AVAILABLE)}"