diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f2e475f602913..4723638fc5e4a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -51,7 +51,7 @@ repos: - id: detect-private-key - repo: https://github.com/codespell-project/codespell - rev: v2.3.0 + rev: v2.4.1 hooks: - id: codespell additional_dependencies: [tomli] @@ -70,7 +70,7 @@ repos: - id: sphinx-lint - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.8.6 + rev: v0.11.4 hooks: # try to fix what is possible - id: ruff @@ -81,7 +81,7 @@ repos: - id: ruff - repo: https://github.com/executablebooks/mdformat - rev: 0.7.21 + rev: 0.7.22 hooks: - id: mdformat additional_dependencies: diff --git a/src/lightning/pytorch/callbacks/timer.py b/src/lightning/pytorch/callbacks/timer.py index b6b74d280427c..91f5fd0e75d9b 100644 --- a/src/lightning/pytorch/callbacks/timer.py +++ b/src/lightning/pytorch/callbacks/timer.py @@ -111,8 +111,8 @@ def __init__( self._duration = duration.total_seconds() if duration is not None else None self._interval = interval self._verbose = verbose - self._start_time: dict[RunningStage, Optional[float]] = {stage: None for stage in RunningStage} - self._end_time: dict[RunningStage, Optional[float]] = {stage: None for stage in RunningStage} + self._start_time: dict[RunningStage, Optional[float]] = dict.fromkeys(RunningStage) + self._end_time: dict[RunningStage, Optional[float]] = dict.fromkeys(RunningStage) self._offset = 0 def start_time(self, stage: str = RunningStage.TRAINING) -> Optional[float]: diff --git a/tests/tests_pytorch/helpers/datasets.py b/tests/tests_pytorch/helpers/datasets.py index 014fb374e5d5e..638d3a2946a74 100644 --- a/tests/tests_pytorch/helpers/datasets.py +++ b/tests/tests_pytorch/helpers/datasets.py @@ -148,7 +148,7 @@ def __init__(self, root: str, num_samples: int = 100, digits: Optional[Sequence] @staticmethod def _prepare_subset(full_data: Tensor, full_targets: Tensor, num_samples: int, digits: Sequence): - classes = {d: 0 for d in digits} + classes = dict.fromkeys(digits, 0) indexes = [] for idx, target in enumerate(full_targets): label = target.item() diff --git a/tests/tests_pytorch/trainer/connectors/test_data_connector.py b/tests/tests_pytorch/trainer/connectors/test_data_connector.py index ceb0418f2cb1d..1bb0d1478e7d3 100644 --- a/tests/tests_pytorch/trainer/connectors/test_data_connector.py +++ b/tests/tests_pytorch/trainer/connectors/test_data_connector.py @@ -497,7 +497,7 @@ def test_dataloader_source_request_from_module(): @pytest.mark.parametrize( - "hook_name", ("on_before_batch_transfer", "transfer_batch_to_device", "on_after_batch_transfer") + "hook_name", ["on_before_batch_transfer", "transfer_batch_to_device", "on_after_batch_transfer"] ) class TestDataHookSelector: def overridden_func(self, batch, *args, **kwargs): diff --git a/tests/tests_pytorch/trainer/logging_/test_logger_connector.py b/tests/tests_pytorch/trainer/logging_/test_logger_connector.py index faf88a09f6499..d3d355edb003b 100644 --- a/tests/tests_pytorch/trainer/logging_/test_logger_connector.py +++ b/tests/tests_pytorch/trainer/logging_/test_logger_connector.py @@ -246,7 +246,7 @@ def test_fx_validator_integration(tmp_path): }) trainer.test(model, verbose=False) - not_supported.update({k: "result collection is not registered yet" for k in not_supported}) + not_supported.update(dict.fromkeys(not_supported, "result collection is not registered yet")) not_supported.update({ "predict_dataloader": "result collection is not registered yet", "on_predict_model_eval": "result collection is not registered yet",