Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] Upgrade isort in pre-commit hook #1270

Merged
merged 1 commit into from
Feb 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,8 @@ repos:
rev: 3.8.3
hooks:
- id: flake8
- repo: https://github.com/asottile/seed-isort-config
rev: v2.2.0
hooks:
- id: seed-isort-config
args: ["--exclude", ".dev"]
- repo: https://github.com/timothycrosley/isort
rev: 4.3.21
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
hooks:
- id: isort
- repo: https://github.com/pre-commit/mirrors-yapf
Expand Down
4 changes: 2 additions & 2 deletions mmseg/datasets/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ def _concat_dataset(cfg, default_args=None):

def build_dataset(cfg, default_args=None):
"""Build datasets."""
from .dataset_wrappers import (ConcatDataset, RepeatDataset,
MultiImageMixDataset)
from .dataset_wrappers import (ConcatDataset, MultiImageMixDataset,
RepeatDataset)
if isinstance(cfg, (list, tuple)):
dataset = ConcatDataset([build_dataset(c, default_args) for c in cfg])
elif cfg['type'] == 'RepeatDataset':
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ split_before_expression_after_opening_paren = true
[isort]
line_length = 79
multi_line_output = 0
known_standard_library = setuptools
extra_standard_library = setuptools
known_first_party = mmseg
known_third_party = PIL,cityscapesscripts,cv2,detail,matplotlib,mmcv,numpy,onnxruntime,packaging,prettytable,pytest,pytorch_sphinx_theme,requests,scipy,seaborn,torch,ts
no_lines_before = STDLIB,LOCALFOLDER
Expand Down
3 changes: 2 additions & 1 deletion tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,10 @@ def test_config_data_pipeline():
CommandLine:
xdoctest -m tests/test_config.py test_config_build_data_pipeline
"""
import numpy as np
from mmcv import Config

from mmseg.datasets.pipelines import Compose
import numpy as np

config_dpath = _get_config_directory()
print('Found config_dpath = {!r}'.format(config_dpath))
Expand Down
3 changes: 2 additions & 1 deletion tests/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,10 @@ def test_mean_fscore():


def test_filename_inputs():
import cv2
import tempfile

import cv2

def save_arr(input_arrays: list, title: str, is_image: bool, dir: str):
filenames = []
SUFFIX = '.png' if is_image else '.npy'
Expand Down
1 change: 1 addition & 0 deletions tests/test_models/test_losses/test_ce_loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def test_ce_loss():
# test loss with class weights from file
import os
import tempfile

import mmcv
import numpy as np
tmp_file = tempfile.NamedTemporaryFile()
Expand Down
1 change: 1 addition & 0 deletions tests/test_models/test_losses/test_dice_loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def test_dice_lose():
# test loss with class weights from file
import os
import tempfile

import mmcv
import numpy as np
tmp_file = tempfile.NamedTemporaryFile()
Expand Down
1 change: 1 addition & 0 deletions tests/test_models/test_losses/test_lovasz_loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def test_lovasz_loss():
# test loss with class weights from file
import os
import tempfile

import mmcv
import numpy as np
tmp_file = tempfile.NamedTemporaryFile()
Expand Down
3 changes: 2 additions & 1 deletion tools/pytorch2onnx.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,9 @@ def pytorch2onnx(model,
None, {net_feed_input[0]: img_list[0].detach().numpy()})[0][0]
# show segmentation results
if show:
import cv2
import os.path as osp

import cv2
img = img_meta_list[0][0]['filename']
if not osp.exists(img):
img = imgs[0][:3, ...].permute(1, 2, 0) * 255
Expand Down