From e87d3f813ef85702a04a0d1226a9a2652552fc8e Mon Sep 17 00:00:00 2001 From: James Butler Date: Wed, 23 Oct 2024 16:48:45 -0400 Subject: [PATCH] apply isort changes Changes were automatically applied by running: python -m isort . Signed-off-by: James Butler --- monai/__init__.py | 4 ++-- monai/apps/detection/transforms/array.py | 3 +-- monai/apps/detection/utils/anchor_utils.py | 1 - monai/apps/pathology/engines/utils.py | 3 +-- monai/apps/pathology/inferers/inferer.py | 3 +-- monai/apps/pathology/metrics/lesion_froc.py | 3 +-- monai/apps/pathology/transforms/post/array.py | 3 +-- monai/bundle/reference_resolver.py | 4 +--- monai/bundle/workflows.py | 3 +-- monai/config/type_definitions.py | 3 +-- monai/data/meta_obj.py | 3 +-- monai/data/meta_tensor.py | 3 +-- monai/engines/evaluator.py | 3 +-- monai/engines/trainer.py | 3 +-- monai/engines/utils.py | 4 +--- monai/handlers/clearml_handlers.py | 3 +-- monai/inferers/utils.py | 4 +--- monai/metrics/utils.py | 3 +-- monai/networks/blocks/attention_utils.py | 1 - monai/networks/blocks/rel_pos_embedding.py | 1 - monai/networks/layers/simplelayers.py | 2 +- monai/networks/layers/vector_quantizer.py | 1 - monai/networks/nets/dynunet.py | 3 +-- monai/networks/nets/quicknat.py | 3 +-- monai/networks/nets/swin_unetr.py | 2 +- monai/networks/nets/vista3d.py | 3 +-- monai/transforms/intensity/dictionary.py | 3 +-- monai/transforms/lazy/functional.py | 3 +-- monai/transforms/spatial/array.py | 4 +--- monai/transforms/utility/dictionary.py | 4 +--- monai/utils/component_store.py | 3 +-- monai/utils/decorators.py | 3 +-- monai/utils/dist.py | 5 +---- monai/utils/module.py | 4 +--- monai/utils/state_cacher.py | 3 +-- tests/test_dynunet.py | 3 +-- tests/test_network_consistency.py | 2 +- 37 files changed, 34 insertions(+), 75 deletions(-) diff --git a/monai/__init__.py b/monai/__init__.py index f6fc8b0646..d92557a8e1 100644 --- a/monai/__init__.py +++ b/monai/__init__.py @@ -11,12 +11,12 @@ from __future__ import annotations +import logging import os import sys -import logging import warnings -from ._version import get_versions +from ._version import get_versions old_showwarning = warnings.showwarning diff --git a/monai/apps/detection/transforms/array.py b/monai/apps/detection/transforms/array.py index 6b92572954..301a636b6c 100644 --- a/monai/apps/detection/transforms/array.py +++ b/monai/apps/detection/transforms/array.py @@ -15,9 +15,8 @@ from __future__ import annotations -from typing import Any - from collections.abc import Sequence +from typing import Any import numpy as np import torch diff --git a/monai/apps/detection/utils/anchor_utils.py b/monai/apps/detection/utils/anchor_utils.py index 145350853a..b750fe0de8 100644 --- a/monai/apps/detection/utils/anchor_utils.py +++ b/monai/apps/detection/utils/anchor_utils.py @@ -39,7 +39,6 @@ from __future__ import annotations - from collections.abc import Sequence import torch diff --git a/monai/apps/pathology/engines/utils.py b/monai/apps/pathology/engines/utils.py index c704dc7469..87ca0f8e76 100644 --- a/monai/apps/pathology/engines/utils.py +++ b/monai/apps/pathology/engines/utils.py @@ -11,9 +11,8 @@ from __future__ import annotations -from typing import Any - from collections.abc import Sequence +from typing import Any import torch diff --git a/monai/apps/pathology/inferers/inferer.py b/monai/apps/pathology/inferers/inferer.py index 4f034f0ad1..392cba221f 100644 --- a/monai/apps/pathology/inferers/inferer.py +++ b/monai/apps/pathology/inferers/inferer.py @@ -11,9 +11,8 @@ from __future__ import annotations -from typing import Any, Callable - from collections.abc import Sequence +from typing import Any, Callable import numpy as np import torch diff --git a/monai/apps/pathology/metrics/lesion_froc.py b/monai/apps/pathology/metrics/lesion_froc.py index bbd7bf4905..138488348a 100644 --- a/monai/apps/pathology/metrics/lesion_froc.py +++ b/monai/apps/pathology/metrics/lesion_froc.py @@ -11,9 +11,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any - from collections.abc import Iterable +from typing import TYPE_CHECKING, Any import numpy as np diff --git a/monai/apps/pathology/transforms/post/array.py b/monai/apps/pathology/transforms/post/array.py index bb50ee4fd9..561ed3ae20 100644 --- a/monai/apps/pathology/transforms/post/array.py +++ b/monai/apps/pathology/transforms/post/array.py @@ -12,9 +12,8 @@ from __future__ import annotations import warnings -from typing import Callable - from collections.abc import Sequence +from typing import Callable import numpy as np import torch diff --git a/monai/bundle/reference_resolver.py b/monai/bundle/reference_resolver.py index 6c5ca776f5..df69b021e1 100644 --- a/monai/bundle/reference_resolver.py +++ b/monai/bundle/reference_resolver.py @@ -13,11 +13,9 @@ import re import warnings -from collections.abc import Sequence +from collections.abc import Iterator, Sequence from typing import Any -from collections.abc import Iterator - from monai.bundle.config_item import ConfigComponent, ConfigExpression, ConfigItem from monai.bundle.utils import DEPRECATED_ID_MAPPING, ID_REF_KEY, ID_SEP_KEY from monai.utils import allow_missing_reference, look_up_option diff --git a/monai/bundle/workflows.py b/monai/bundle/workflows.py index f425d8fd28..3ecd5dfbc5 100644 --- a/monai/bundle/workflows.py +++ b/monai/bundle/workflows.py @@ -16,13 +16,12 @@ import sys import time from abc import ABC, abstractmethod +from collections.abc import Sequence from copy import copy from logging.config import fileConfig from pathlib import Path from typing import Any -from collections.abc import Sequence - from monai.apps.utils import get_logger from monai.bundle.config_parser import ConfigParser from monai.bundle.properties import InferProperties, MetaProperties, TrainProperties diff --git a/monai/config/type_definitions.py b/monai/config/type_definitions.py index cf6a2957ee..48c0547e31 100644 --- a/monai/config/type_definitions.py +++ b/monai/config/type_definitions.py @@ -12,9 +12,8 @@ from __future__ import annotations import os -from typing import TypeVar, Union - from collections.abc import Collection, Hashable, Iterable, Sequence +from typing import TypeVar, Union import numpy as np import torch diff --git a/monai/data/meta_obj.py b/monai/data/meta_obj.py index d951d69b04..15e6e8be15 100644 --- a/monai/data/meta_obj.py +++ b/monai/data/meta_obj.py @@ -13,11 +13,10 @@ import itertools import pprint +from collections.abc import Iterable from copy import deepcopy from typing import Any -from collections.abc import Iterable - import numpy as np import torch diff --git a/monai/data/meta_tensor.py b/monai/data/meta_tensor.py index 88e55c74da..ac171e8508 100644 --- a/monai/data/meta_tensor.py +++ b/monai/data/meta_tensor.py @@ -13,11 +13,10 @@ import functools import warnings +from collections.abc import Sequence from copy import deepcopy from typing import Any -from collections.abc import Sequence - import numpy as np import torch diff --git a/monai/engines/evaluator.py b/monai/engines/evaluator.py index 8c0972ae7f..d70a39726b 100644 --- a/monai/engines/evaluator.py +++ b/monai/engines/evaluator.py @@ -12,9 +12,8 @@ from __future__ import annotations import warnings -from typing import TYPE_CHECKING, Any, Callable - from collections.abc import Iterable, Sequence +from typing import TYPE_CHECKING, Any, Callable import torch from torch.utils.data import DataLoader diff --git a/monai/engines/trainer.py b/monai/engines/trainer.py index 0ca9d40a26..a0be86bae5 100644 --- a/monai/engines/trainer.py +++ b/monai/engines/trainer.py @@ -12,9 +12,8 @@ from __future__ import annotations import warnings -from typing import TYPE_CHECKING, Any, Callable - from collections.abc import Iterable, Sequence +from typing import TYPE_CHECKING, Any, Callable import torch from torch.optim.optimizer import Optimizer diff --git a/monai/engines/utils.py b/monai/engines/utils.py index 74612f7116..8e19a18601 100644 --- a/monai/engines/utils.py +++ b/monai/engines/utils.py @@ -12,11 +12,9 @@ from __future__ import annotations from abc import ABC, abstractmethod -from collections.abc import Callable, Sequence +from collections.abc import Callable, Mapping, Sequence from typing import TYPE_CHECKING, Any, cast -from collections.abc import Mapping - import torch import torch.nn as nn diff --git a/monai/handlers/clearml_handlers.py b/monai/handlers/clearml_handlers.py index 11f9dca24f..0aa2a5cc08 100644 --- a/monai/handlers/clearml_handlers.py +++ b/monai/handlers/clearml_handlers.py @@ -11,9 +11,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any - from collections.abc import Mapping, Sequence +from typing import TYPE_CHECKING, Any from monai.utils import optional_import diff --git a/monai/inferers/utils.py b/monai/inferers/utils.py index 8bb2941529..edaf736091 100644 --- a/monai/inferers/utils.py +++ b/monai/inferers/utils.py @@ -12,11 +12,9 @@ from __future__ import annotations import itertools -from collections.abc import Callable, Mapping, Sequence +from collections.abc import Callable, Iterable, Mapping, Sequence from typing import Any -from collections.abc import Iterable - import numpy as np import torch import torch.nn.functional as F diff --git a/monai/metrics/utils.py b/monai/metrics/utils.py index 43bd5a3483..96d60c9098 100644 --- a/monai/metrics/utils.py +++ b/monai/metrics/utils.py @@ -12,12 +12,11 @@ from __future__ import annotations import warnings +from collections.abc import Iterable, Sequence from functools import lru_cache, partial from types import ModuleType from typing import Any -from collections.abc import Iterable, Sequence - import numpy as np import torch diff --git a/monai/networks/blocks/attention_utils.py b/monai/networks/blocks/attention_utils.py index c5666d7728..a8dfcd7df3 100644 --- a/monai/networks/blocks/attention_utils.py +++ b/monai/networks/blocks/attention_utils.py @@ -9,7 +9,6 @@ from __future__ import annotations - import torch import torch.nn.functional as F from torch import nn diff --git a/monai/networks/blocks/rel_pos_embedding.py b/monai/networks/blocks/rel_pos_embedding.py index c7546bdb4e..995e179c6e 100644 --- a/monai/networks/blocks/rel_pos_embedding.py +++ b/monai/networks/blocks/rel_pos_embedding.py @@ -9,7 +9,6 @@ from __future__ import annotations - from collections.abc import Iterable import torch diff --git a/monai/networks/layers/simplelayers.py b/monai/networks/layers/simplelayers.py index 98417f17aa..8093796f87 100644 --- a/monai/networks/layers/simplelayers.py +++ b/monai/networks/layers/simplelayers.py @@ -12,8 +12,8 @@ from __future__ import annotations import math -from copy import deepcopy from collections.abc import Sequence +from copy import deepcopy import torch import torch.nn.functional as F diff --git a/monai/networks/layers/vector_quantizer.py b/monai/networks/layers/vector_quantizer.py index a865650c44..8ee85bdb79 100644 --- a/monai/networks/layers/vector_quantizer.py +++ b/monai/networks/layers/vector_quantizer.py @@ -11,7 +11,6 @@ from __future__ import annotations - from collections.abc import Sequence import torch diff --git a/monai/networks/nets/dynunet.py b/monai/networks/nets/dynunet.py index 6c87387bd2..33d6c18c9f 100644 --- a/monai/networks/nets/dynunet.py +++ b/monai/networks/nets/dynunet.py @@ -11,9 +11,8 @@ # isort: dont-add-import: from __future__ import annotations -from typing import Optional, Union - from collections.abc import Sequence +from typing import Optional, Union import torch import torch.nn as nn diff --git a/monai/networks/nets/quicknat.py b/monai/networks/nets/quicknat.py index ceeb4b863e..e10bb1d14d 100644 --- a/monai/networks/nets/quicknat.py +++ b/monai/networks/nets/quicknat.py @@ -11,9 +11,8 @@ from __future__ import annotations -from typing import Optional, Union - from collections.abc import Sequence +from typing import Optional, Union import torch import torch.nn as nn diff --git a/monai/networks/nets/swin_unetr.py b/monai/networks/nets/swin_unetr.py index c8fb76ad8b..832135ad06 100644 --- a/monai/networks/nets/swin_unetr.py +++ b/monai/networks/nets/swin_unetr.py @@ -13,6 +13,7 @@ import itertools from collections.abc import Sequence +from typing import Final import numpy as np import torch @@ -20,7 +21,6 @@ import torch.nn.functional as F import torch.utils.checkpoint as checkpoint from torch.nn import LayerNorm -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/networks/nets/vista3d.py b/monai/networks/nets/vista3d.py index fa426a40c2..460f8d3ee4 100644 --- a/monai/networks/nets/vista3d.py +++ b/monai/networks/nets/vista3d.py @@ -12,9 +12,8 @@ from __future__ import annotations import math -from typing import Any, Callable, Optional - from collections.abc import Sequence +from typing import Any, Callable, Optional import numpy as np import torch diff --git a/monai/transforms/intensity/dictionary.py b/monai/transforms/intensity/dictionary.py index c5e7add79d..f2b1a2fd40 100644 --- a/monai/transforms/intensity/dictionary.py +++ b/monai/transforms/intensity/dictionary.py @@ -17,9 +17,8 @@ from __future__ import annotations -from typing import Callable - from collections.abc import Hashable, Mapping, Sequence +from typing import Callable import numpy as np diff --git a/monai/transforms/lazy/functional.py b/monai/transforms/lazy/functional.py index 518c74e414..a33d76807c 100644 --- a/monai/transforms/lazy/functional.py +++ b/monai/transforms/lazy/functional.py @@ -11,9 +11,8 @@ from __future__ import annotations -from typing import Any - from collections.abc import Mapping, Sequence +from typing import Any import torch diff --git a/monai/transforms/spatial/array.py b/monai/transforms/spatial/array.py index 18ea0da23b..e4ed196eff 100644 --- a/monai/transforms/spatial/array.py +++ b/monai/transforms/spatial/array.py @@ -15,13 +15,11 @@ from __future__ import annotations import warnings -from collections.abc import Callable +from collections.abc import Callable, Sequence from copy import deepcopy from itertools import zip_longest from typing import Any, Optional, Union, cast -from collections.abc import Sequence - import numpy as np import torch diff --git a/monai/transforms/utility/dictionary.py b/monai/transforms/utility/dictionary.py index da43914aba..65c721e48e 100644 --- a/monai/transforms/utility/dictionary.py +++ b/monai/transforms/utility/dictionary.py @@ -18,12 +18,10 @@ from __future__ import annotations import re -from collections.abc import Callable, Hashable, Mapping +from collections.abc import Callable, Hashable, Mapping, Sequence from copy import deepcopy from typing import Any, cast -from collections.abc import Sequence - import numpy as np import torch diff --git a/monai/utils/component_store.py b/monai/utils/component_store.py index 44be6efe94..bf0d632ddd 100644 --- a/monai/utils/component_store.py +++ b/monai/utils/component_store.py @@ -12,12 +12,11 @@ from __future__ import annotations from collections import namedtuple +from collections.abc import Iterable from keyword import iskeyword from textwrap import dedent, indent from typing import Any, Callable, TypeVar -from collections.abc import Iterable - T = TypeVar("T") diff --git a/monai/utils/decorators.py b/monai/utils/decorators.py index 0c3bf6ba6f..a784510c64 100644 --- a/monai/utils/decorators.py +++ b/monai/utils/decorators.py @@ -15,9 +15,8 @@ __all__ = ["RestartGenerator", "MethodReplacer"] -from typing import Callable - from collections.abc import Generator +from typing import Callable class RestartGenerator: diff --git a/monai/utils/dist.py b/monai/utils/dist.py index 9c4ad64708..47da2bee6e 100644 --- a/monai/utils/dist.py +++ b/monai/utils/dist.py @@ -14,10 +14,7 @@ import warnings from collections.abc import Callable from logging import Filter - -from typing import Literal - -from typing import overload +from typing import Literal, overload import torch import torch.distributed as dist diff --git a/monai/utils/module.py b/monai/utils/module.py index f2acb28119..1f7f8aecfc 100644 --- a/monai/utils/module.py +++ b/monai/utils/module.py @@ -18,7 +18,7 @@ import re import sys import warnings -from collections.abc import Callable, Collection, Hashable, Mapping +from collections.abc import Callable, Collection, Hashable, Iterable, Mapping from functools import partial, wraps from importlib import import_module from pkgutil import walk_packages @@ -27,8 +27,6 @@ from types import FunctionType, ModuleType from typing import Any, cast -from collections.abc import Iterable - import torch # bundle config system flags diff --git a/monai/utils/state_cacher.py b/monai/utils/state_cacher.py index 255e15a7e4..60a074544b 100644 --- a/monai/utils/state_cacher.py +++ b/monai/utils/state_cacher.py @@ -15,11 +15,10 @@ import os import pickle import tempfile +from collections.abc import Hashable from types import ModuleType from typing import Any -from collections.abc import Hashable - import torch from torch.serialization import DEFAULT_PROTOCOL diff --git a/tests/test_dynunet.py b/tests/test_dynunet.py index e173049a95..7c4882fcbb 100644 --- a/tests/test_dynunet.py +++ b/tests/test_dynunet.py @@ -13,9 +13,8 @@ import platform import unittest -from typing import Any - from collections.abc import Sequence +from typing import Any import torch from parameterized import parameterized diff --git a/tests/test_network_consistency.py b/tests/test_network_consistency.py index 6949bb359f..bcfd448144 100644 --- a/tests/test_network_consistency.py +++ b/tests/test_network_consistency.py @@ -14,8 +14,8 @@ import json import os import unittest -from glob import glob from collections.abc import Sequence +from glob import glob from unittest.case import skipIf import torch