Skip to content

Commit 9b38586

Browse files
committed
Format fixes and script fixes
Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
1 parent 87c6fee commit 9b38586

22 files changed

Lines changed: 32 additions & 42 deletions

File tree

.github/workflows/cicd_tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ jobs:
198198
name: Install torch cpu from pytorch.org (Windows only)
199199
run: |
200200
python -m pip install torch==${PYTORCH_VER1} torchvision==${TORCHVISION_VER}+cpu --index-url https://download.pytorch.org/whl/cpu
201+
shell: bash
201202
- if: runner.os == 'Linux'
202203
name: Install itk pre-release (Linux only)
203204
run: |

monai/_version.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
import re
1616
import subprocess
1717
import sys
18-
from typing import Callable, Dict
18+
from typing import Dict
19+
from collections.abc import Callable
1920
import functools
2021

2122

@@ -54,8 +55,8 @@ class NotThisMethod(Exception):
5455
"""Exception raised if a method is not valid for the current scenario."""
5556

5657

57-
LONG_VERSION_PY: Dict[str, str] = {}
58-
HANDLERS: Dict[str, Dict[str, Callable]] = {}
58+
LONG_VERSION_PY: dict[str, str] = {}
59+
HANDLERS: dict[str, dict[str, Callable]] = {}
5960

6061

6162
def register_vcs_handler(vcs, method): # decorator
@@ -145,7 +146,7 @@ def git_get_keywords(versionfile_abs):
145146
# _version.py.
146147
keywords = {}
147148
try:
148-
with open(versionfile_abs, "r") as fobj:
149+
with open(versionfile_abs) as fobj:
149150
for line in fobj:
150151
if line.strip().startswith("git_refnames ="):
151152
mo = re.search(r'=\s*"(.*)"', line)

monai/apps/pathology/inferers/inferer.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@
1111

1212
from __future__ import annotations
1313

14-
from collections.abc import Sequence
14+
from collections.abc import Callable, Sequence
1515
from typing import Any
16-
from collections.abc import Callable
1716

1817
import numpy as np
1918
import torch

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
from __future__ import annotations
1313

1414
import warnings
15-
from collections.abc import Sequence
16-
from collections.abc import Callable
15+
from collections.abc import Callable, Sequence
1716

1817
import numpy as np
1918
import torch

monai/bundle/scripts.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,13 @@
1717
import re
1818
import urllib
1919
import warnings
20-
from collections.abc import Mapping, Sequence
20+
from collections.abc import Callable, Mapping, Sequence
2121
from functools import partial
2222
from pathlib import Path
2323
from pydoc import locate
2424
from shutil import copyfile
2525
from textwrap import dedent
2626
from typing import Any
27-
from collections.abc import Callable
2827

2928
import torch
3029
from torch.cuda import is_available

monai/config/type_definitions.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,21 @@
5353
# convenience to end-users. All supplied values will be
5454
# internally converted to a tuple of `Hashable`'s before
5555
# use
56-
KeysCollection = Union[Collection[Hashable], Hashable]
56+
KeysCollection = Collection[Hashable] | Hashable
5757

5858
#: IndexSelection
5959
#
6060
# The IndexSelection type is used to for defining variables
6161
# that store a subset of indices to select items from a List or Array like objects.
6262
# The indices must be integers, and if a container of indices is specified, the
6363
# container must be iterable.
64-
IndexSelection = Union[Iterable[int], int]
64+
IndexSelection = Iterable[int] | int
6565

6666
#: Type of datatypes: Adapted from https://github.com/numpy/numpy/blob/v1.21.4/numpy/typing/_dtype_like.py#L121
67-
DtypeLike = Union[np.dtype, type, str, None]
67+
DtypeLike = np.dtype | type | str | None
6868

6969
#: NdarrayOrTensor: Union of numpy.ndarray and torch.Tensor to be used for typing
70-
NdarrayOrTensor = Union[np.ndarray, torch.Tensor]
70+
NdarrayOrTensor = np.ndarray | torch.Tensor
7171

7272
#: NdarrayTensor
7373
#
@@ -76,11 +76,11 @@
7676
NdarrayTensor = TypeVar("NdarrayTensor", bound=NdarrayOrTensor)
7777

7878
#: TensorOrList: The TensorOrList type is used for defining `batch-first Tensor` or `list of channel-first Tensor`.
79-
TensorOrList = Union[torch.Tensor, Sequence[torch.Tensor]]
79+
TensorOrList = torch.Tensor | Sequence[torch.Tensor]
8080

8181
#: PathLike: The PathLike type is used for defining a file path.
82-
PathLike = Union[str, os.PathLike]
82+
PathLike = str | os.PathLike
8383

8484
#: SequenceStr
8585
# string or a sequence of strings for `mode` types.
86-
SequenceStr = Union[Sequence[str], str]
86+
SequenceStr = Sequence[str] | str

monai/data/image_reader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
if TYPE_CHECKING:
6161
import cupy
6262

63-
NdarrayOrCupy = Union[np.ndarray, cupy.ndarray]
63+
NdarrayOrCupy = np.ndarray | cupy.ndarray
6464
else:
6565
NdarrayOrCupy = Any
6666

monai/engines/evaluator.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212
from __future__ import annotations
1313

1414
import warnings
15-
from collections.abc import Iterable, Sequence
15+
from collections.abc import Callable, Iterable, Sequence
1616
from typing import TYPE_CHECKING, Any
17-
from collections.abc import Callable
1817

1918
import torch
2019
from torch.utils.data import DataLoader

monai/engines/trainer.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212
from __future__ import annotations
1313

1414
import warnings
15-
from collections.abc import Iterable, Sequence
15+
from collections.abc import Callable, Iterable, Sequence
1616
from typing import TYPE_CHECKING, Any
17-
from collections.abc import Callable
1817

1918
import torch
2019
from torch.optim.optimizer import Optimizer

monai/networks/nets/vista3d.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212
from __future__ import annotations
1313

1414
import math
15-
from collections.abc import Sequence
15+
from collections.abc import Callable, Sequence
1616
from typing import Any
17-
from collections.abc import Callable
1817

1918
import numpy as np
2019
import torch

0 commit comments

Comments
 (0)