From 2a2a1fb367606c74e0bd7d9528c9f22834ba6fc3 Mon Sep 17 00:00:00 2001 From: James Butler Date: Tue, 15 Oct 2024 17:58:53 -0400 Subject: [PATCH] Apply pyupgrade for Python 3.8+ syntax This should have been included in https://github.com/Project-MONAI/MONAI/commit/104a360f953b5d720b3eb8f5b1a0546540e5e391 when Python 3.7 support was dropped. Changes were automatically applied by running: pre_commit run --all-files Signed-off-by: James Butler --- .pre-commit-config.yaml | 4 ++-- monai/networks/nets/swin_unetr.py | 2 +- monai/utils/dist.py | 4 +--- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1ab89f1f16..e686e72118 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -37,7 +37,7 @@ repos: rev: v3.18.0 hooks: - id: pyupgrade - args: [--py37-plus] + args: [--py38-plus] name: Upgrade code excluding monai networks exclude: | (?x)( @@ -49,7 +49,7 @@ repos: ^monai/data/grid_dataset.py ) - id: pyupgrade - args: [--py37-plus, --keep-runtime-typing] + args: [--py38-plus, --keep-runtime-typing] name: Upgrade monai networks files: (?x)( ^monai/networks/| diff --git a/monai/networks/nets/swin_unetr.py b/monai/networks/nets/swin_unetr.py index 714d986f4b..c8fb76ad8b 100644 --- a/monai/networks/nets/swin_unetr.py +++ b/monai/networks/nets/swin_unetr.py @@ -20,7 +20,7 @@ import torch.nn.functional as F import torch.utils.checkpoint as checkpoint from torch.nn import LayerNorm -from typing_extensions import Final +from typing import Final from monai.networks.blocks import MLPBlock as Mlp from monai.networks.blocks import PatchEmbed, UnetOutBlock, UnetrBasicBlock, UnetrUpBlock diff --git a/monai/utils/dist.py b/monai/utils/dist.py index c7ff988027..9c4ad64708 100644 --- a/monai/utils/dist.py +++ b/monai/utils/dist.py @@ -11,13 +11,11 @@ from __future__ import annotations -import sys import warnings from collections.abc import Callable from logging import Filter -if sys.version_info >= (3, 8): - from typing import Literal +from typing import Literal from typing import overload