Skip to content

Commit e4688ae

Browse files
authored
Fix isort failures in utilities (#5530)
Remove from skipped module in pyproject.toml and fix failures on: - pytorch_lightning/utilities/*.py
1 parent 8629048 commit e4688ae

File tree

9 files changed

+20
-27
lines changed

9 files changed

+20
-27
lines changed

pyproject.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,6 @@ skip_glob = [
6565

6666
# todo
6767
"pytorch_lightning/tuner/*",
68-
69-
70-
# todo
71-
"pytorch_lightning/utilities/*",
7268
]
7369
profile = "black"
7470
line_length = 120

pytorch_lightning/utilities/__init__.py

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,31 +22,25 @@
2222
rank_zero_only,
2323
rank_zero_warn,
2424
)
25-
from pytorch_lightning.utilities.enums import ( # noqa: F401
26-
LightningEnum,
27-
AMPType,
28-
DistributedType,
29-
DeviceType,
30-
)
25+
from pytorch_lightning.utilities.enums import AMPType, DeviceType, DistributedType, LightningEnum # noqa: F401
3126
from pytorch_lightning.utilities.imports import ( # noqa: F401
3227
_APEX_AVAILABLE,
33-
_NATIVE_AMP_AVAILABLE,
34-
_XLA_AVAILABLE,
35-
_OMEGACONF_AVAILABLE,
36-
_HYDRA_AVAILABLE,
37-
_HOROVOD_AVAILABLE,
38-
_TORCHTEXT_AVAILABLE,
28+
_BOLTS_AVAILABLE,
3929
_FAIRSCALE_AVAILABLE,
40-
_RPC_AVAILABLE,
41-
_GROUP_AVAILABLE,
4230
_FAIRSCALE_PIPE_AVAILABLE,
43-
_BOLTS_AVAILABLE,
31+
_GROUP_AVAILABLE,
32+
_HOROVOD_AVAILABLE,
33+
_HYDRA_AVAILABLE,
4434
_module_available,
35+
_NATIVE_AMP_AVAILABLE,
36+
_OMEGACONF_AVAILABLE,
37+
_RPC_AVAILABLE,
38+
_TORCHTEXT_AVAILABLE,
39+
_XLA_AVAILABLE,
4540
)
4641
from pytorch_lightning.utilities.parsing import AttributeDict, flatten_dict, is_picklable # noqa: F401
4742
from pytorch_lightning.utilities.xla_device import XLADeviceUtils # noqa: F401
4843

49-
5044
_TPU_AVAILABLE = XLADeviceUtils.tpu_device_exists()
5145

5246
FLOAT16_EPSILON = numpy.finfo(numpy.float16).eps

pytorch_lightning/utilities/argparse.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
import os
1616
from argparse import ArgumentParser, Namespace
1717
from contextlib import suppress
18-
from typing import Dict, Union, List, Tuple, Any
18+
from typing import Any, Dict, List, Tuple, Union
19+
1920
from pytorch_lightning.utilities import parsing
2021

2122

pytorch_lightning/utilities/data.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@
1313
# limitations under the License.
1414

1515
from distutils.version import LooseVersion
16+
from typing import Union
17+
1618
import torch
1719
from torch.utils.data import DataLoader, IterableDataset
1820

1921
from pytorch_lightning.utilities import rank_zero_warn
20-
from typing import Union
2122

2223

2324
def has_iterable_dataset(dataloader: DataLoader):

pytorch_lightning/utilities/debugging.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import time
1717
from collections import Counter
1818
from functools import wraps
19-
from typing import Callable, Any, Optional
19+
from typing import Any, Callable, Optional
2020

2121

2222
def enabled_only(fn: Callable):

pytorch_lightning/utilities/device_dtype_mixin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from typing import Union, Optional
15+
from typing import Optional, Union
1616

1717
import torch
1818
from torch.nn import Module

pytorch_lightning/utilities/device_parser.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
from typing import Any, List, MutableSequence, Optional, Union
15+
1416
import torch
15-
from typing import Union, Any, List, Optional, MutableSequence
1617

1718
from pytorch_lightning.utilities import _TPU_AVAILABLE
1819
from pytorch_lightning.utilities.exceptions import MisconfigurationException

pytorch_lightning/utilities/model_helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
from typing import Union
1616

17-
from pytorch_lightning.core.lightning import LightningModule
1817
from pytorch_lightning.core.datamodule import LightningDataModule
18+
from pytorch_lightning.core.lightning import LightningModule
1919

2020

2121
def is_overridden(method_name: str, model: Union[LightningModule, LightningDataModule]) -> bool:

pytorch_lightning/utilities/parsing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import inspect
1616
import pickle
1717
from argparse import Namespace
18-
from typing import Dict, Union, Tuple
18+
from typing import Dict, Tuple, Union
1919

2020
from pytorch_lightning.utilities import rank_zero_warn
2121

0 commit comments

Comments
 (0)