Skip to content

Commit 54e6514

Browse files
committed
Apply pyupgrade for Python 3.9+ syntax
This should have been included in 14b086b when Python 3.8 support was dropped. Changes were automatically applied by running: pre_commit run --all-files Signed-off-by: James Butler <james.butler@revvity.com>
1 parent 2ce81c7 commit 54e6514

52 files changed

Lines changed: 143 additions & 91 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ repos:
3737
rev: v3.18.0
3838
hooks:
3939
- id: pyupgrade
40-
args: [--py38-plus, --keep-runtime-typing]
40+
args: [--py39-plus, --keep-runtime-typing]
4141
name: Upgrade code with exceptions
4242
exclude: |
4343
(?x)(

monai/apps/detection/networks/retinanet_network.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
import math
4343
import warnings
4444
from collections.abc import Callable, Sequence
45-
from typing import Any, Dict
45+
from typing import Any
4646

4747
import torch
4848
from torch import Tensor, nn
@@ -330,7 +330,7 @@ def forward(self, images: Tensor) -> Any:
330330
features = self.feature_extractor(images)
331331
if isinstance(features, Tensor):
332332
feature_maps = [features]
333-
elif torch.jit.isinstance(features, Dict[str, Tensor]):
333+
elif torch.jit.isinstance(features, dict[str, Tensor]):
334334
feature_maps = list(features.values())
335335
else:
336336
feature_maps = list(features)

monai/apps/detection/transforms/array.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515

1616
from __future__ import annotations
1717

18-
from typing import Any, Sequence
18+
from typing import Any
19+
20+
from collections.abc import Sequence
1921

2022
import numpy as np
2123
import torch

monai/apps/detection/utils/anchor_utils.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939

4040
from __future__ import annotations
4141

42-
from typing import List, Sequence
42+
43+
from collections.abc import Sequence
4344

4445
import torch
4546
from torch import Tensor, nn
@@ -106,7 +107,7 @@ class AnchorGenerator(nn.Module):
106107
anchor_generator = AnchorGenerator(sizes, aspect_ratios)
107108
"""
108109

109-
__annotations__ = {"cell_anchors": List[torch.Tensor]}
110+
__annotations__ = {"cell_anchors": list[torch.Tensor]}
110111

111112
def __init__(
112113
self,
@@ -364,7 +365,7 @@ class AnchorGeneratorWithAnchorShape(AnchorGenerator):
364365
anchor_generator = AnchorGeneratorWithAnchorShape(feature_map_scales, base_anchor_shapes)
365366
"""
366367

367-
__annotations__ = {"cell_anchors": List[torch.Tensor]}
368+
__annotations__ = {"cell_anchors": list[torch.Tensor]}
368369

369370
def __init__(
370371
self,

monai/apps/generation/maisi/networks/autoencoderkl_maisi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
import gc
1515
import logging
16-
from typing import Sequence
16+
from collections.abc import Sequence
1717

1818
import torch
1919
import torch.nn as nn

monai/apps/generation/maisi/networks/controlnet_maisi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
from __future__ import annotations
1313

14-
from typing import Sequence
14+
from collections.abc import Sequence
1515

1616
import torch
1717

monai/apps/pathology/engines/utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111

1212
from __future__ import annotations
1313

14-
from typing import Any, Sequence
14+
from typing import Any
15+
16+
from collections.abc import Sequence
1517

1618
import torch
1719

monai/apps/pathology/inferers/inferer.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111

1212
from __future__ import annotations
1313

14-
from typing import Any, Callable, Sequence
14+
from typing import Any, Callable
15+
16+
from collections.abc import Sequence
1517

1618
import numpy as np
1719
import torch

monai/apps/pathology/metrics/lesion_froc.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111

1212
from __future__ import annotations
1313

14-
from typing import TYPE_CHECKING, Any, Iterable
14+
from typing import TYPE_CHECKING, Any
15+
16+
from collections.abc import Iterable
1517

1618
import numpy as np
1719

monai/apps/pathology/transforms/post/array.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
from __future__ import annotations
1313

1414
import warnings
15-
from typing import Callable, Sequence
15+
from typing import Callable
16+
17+
from collections.abc import Sequence
1618

1719
import numpy as np
1820
import torch

0 commit comments

Comments
 (0)