Skip to content

Commit

Permalink
lint: isort pre-commit & misc improvements (#3749)
Browse files Browse the repository at this point in the history
* test: clean flake8 config root clutter

* test: pre-commit: add isort

Compatible with black (see PyCQA/isort#694)

* lint: reorder imports

* lint: more complex imports

* lint: fix deepsource

* config: isort: add first party dvc

* tests: restyled: add isort

* temp commit to revert before merge

* Revert "temp commit to revert before merge"

This reverts commit 11db0fd.
  • Loading branch information
casperdcl authored May 6, 2020
1 parent e383106 commit 2bb7257
Show file tree
Hide file tree
Showing 190 changed files with 445 additions and 518 deletions.
7 changes: 0 additions & 7 deletions .flake8

This file was deleted.

5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ repos:
language_version: python3
repo: https://github.com/ambv/black
rev: 19.10b0
- hooks:
- id: isort
language_version: python3
repo: https://github.com/timothycrosley/isort
rev: 4.3.21
- hooks:
- id: flake8
language_version: python3
Expand Down
9 changes: 9 additions & 0 deletions .restyled.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,12 @@ restylers:
- "**/*.py"
interpreters:
- python
- name: isort
image: restyled/restyler-isort:v4.3.21
command:
- isort
arguments: []
include:
- "**/*.py"
interpreters:
- python
1 change: 0 additions & 1 deletion dvc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@
import dvc.logger
from dvc.version import __version__ # noqa: F401


dvc.logger.setup()
3 changes: 1 addition & 2 deletions dvc/analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
import logging
import os
import platform
import requests
import sys
import tempfile
import uuid

import distro
import requests

from dvc import __version__
from dvc.config import Config, to_bool
Expand All @@ -20,7 +20,6 @@
from dvc.utils import env2bool, is_binary
from dvc.utils.fs import makedirs


logger = logging.getLogger(__name__)


Expand Down
5 changes: 3 additions & 2 deletions dvc/api.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import os
from contextlib import contextmanager, _GeneratorContextManager as GCM
from contextlib import _GeneratorContextManager as GCM
from contextlib import contextmanager

from dvc.repo import Repo
from dvc.exceptions import DvcException, NotDvcRepoError
from dvc.external_repo import external_repo
from dvc.repo import Repo


class UrlNotDvcRepoError(DvcException):
Expand Down
9 changes: 4 additions & 5 deletions dvc/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@
gc,
get,
get_url,
git_hook,
imp,
imp_url,
init,
install,
ls,
lock,
ls,
metrics,
params,
move,
params,
pipeline,
plot,
remote,
remove,
repro,
Expand All @@ -34,13 +36,10 @@
unprotect,
update,
version,
git_hook,
plot,
)
from .command.base import fix_subparsers
from .exceptions import DvcParserError


logger = logging.getLogger(__name__)

COMMANDS = [
Expand Down
2 changes: 1 addition & 1 deletion dvc/command/add.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import argparse
import logging

from dvc.command.base import append_doc_link, CmdBase
from dvc.command.base import CmdBase, append_doc_link
from dvc.exceptions import DvcException, RecursiveAddingWhileUsingFilename

logger = logging.getLogger(__name__)
Expand Down
1 change: 0 additions & 1 deletion dvc/command/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import logging


logger = logging.getLogger(__name__)


Expand Down
3 changes: 1 addition & 2 deletions dvc/command/checkout.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

import colorama

from dvc.command.base import append_doc_link
from dvc.command.base import CmdBase
from dvc.command.base import CmdBase, append_doc_link
from dvc.exceptions import CheckoutError
from dvc.utils.humanize import get_summary

Expand Down
4 changes: 1 addition & 3 deletions dvc/command/commit.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import argparse
import logging

from dvc.command.base import append_doc_link
from dvc.command.base import CmdBase
from dvc.command.base import CmdBase, append_doc_link
from dvc.exceptions import DvcException


logger = logging.getLogger(__name__)


Expand Down
2 changes: 1 addition & 1 deletion dvc/command/config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import argparse
import logging

from dvc.command.base import append_doc_link, CmdBaseNoRepo
from dvc.command.base import CmdBaseNoRepo, append_doc_link
from dvc.config import Config, ConfigError

logger = logging.getLogger(__name__)
Expand Down
3 changes: 1 addition & 2 deletions dvc/command/daemon.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from dvc.command.base import CmdBaseNoRepo
from dvc.command.base import fix_subparsers
from dvc.command.base import CmdBaseNoRepo, fix_subparsers


class CmdDaemonBase(CmdBaseNoRepo):
Expand Down
14 changes: 6 additions & 8 deletions dvc/command/data_sync.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import argparse
import logging

from dvc.command.base import append_doc_link
from dvc.command.base import CmdBase
from dvc.command.base import CmdBase, append_doc_link
from dvc.command.checkout import log_changes
from dvc.exceptions import CheckoutError, DvcException
from dvc.utils.humanize import get_summary
from dvc.exceptions import DvcException, CheckoutError


logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -88,24 +86,24 @@ def shared_parent_parser():
from dvc.cli import get_parent_parser

# Parent parser used in pull/push/status
shared_parent_parser = argparse.ArgumentParser(
parent_parser = argparse.ArgumentParser(
add_help=False, parents=[get_parent_parser()]
)
shared_parent_parser.add_argument(
parent_parser.add_argument(
"-j",
"--jobs",
type=int,
help="Number of jobs to run simultaneously.",
metavar="<number>",
)
shared_parent_parser.add_argument(
parent_parser.add_argument(
"targets",
nargs="*",
help="Limit command scope to these DVC-files. "
"Using -R, directories to search DVC-files in can also be given.",
)

return shared_parent_parser
return parent_parser


def add_parser(subparsers, _parent_parser):
Expand Down
4 changes: 1 addition & 3 deletions dvc/command/destroy.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
import logging

import dvc.prompt as prompt
from dvc.command.base import append_doc_link
from dvc.command.base import CmdBase
from dvc.command.base import CmdBase, append_doc_link
from dvc.exceptions import DvcException


logger = logging.getLogger(__name__)


Expand Down
1 change: 0 additions & 1 deletion dvc/command/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from dvc.command.base import CmdBase, append_doc_link
from dvc.exceptions import DvcException


logger = logging.getLogger(__name__)


Expand Down
4 changes: 1 addition & 3 deletions dvc/command/gc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
import os

import dvc.prompt as prompt
from dvc.command.base import append_doc_link
from dvc.command.base import CmdBase

from dvc.command.base import CmdBase, append_doc_link

logger = logging.getLogger(__name__)

Expand Down
3 changes: 1 addition & 2 deletions dvc/command/get.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import argparse
import logging

from .base import append_doc_link
from .base import CmdBaseNoRepo
from dvc.exceptions import DvcException

from .base import CmdBaseNoRepo, append_doc_link

logger = logging.getLogger(__name__)

Expand Down
3 changes: 1 addition & 2 deletions dvc/command/get_url.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import argparse
import logging

from .base import append_doc_link
from .base import CmdBaseNoRepo
from dvc.exceptions import DvcException

from .base import CmdBaseNoRepo, append_doc_link

logger = logging.getLogger(__name__)

Expand Down
4 changes: 1 addition & 3 deletions dvc/command/imp.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import argparse
import logging

from dvc.command.base import append_doc_link
from dvc.command.base import CmdBase
from dvc.command.base import CmdBase, append_doc_link
from dvc.exceptions import DvcException


logger = logging.getLogger(__name__)


Expand Down
4 changes: 1 addition & 3 deletions dvc/command/imp_url.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import argparse
import logging

from dvc.command.base import append_doc_link
from dvc.command.base import CmdBase
from dvc.command.base import CmdBase, append_doc_link
from dvc.exceptions import DvcException


logger = logging.getLogger(__name__)


Expand Down
4 changes: 1 addition & 3 deletions dvc/command/init.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import argparse
import logging

from dvc.command.base import append_doc_link
from dvc.command.base import CmdBaseNoRepo

from dvc.command.base import CmdBaseNoRepo, append_doc_link

logger = logging.getLogger(__name__)

Expand Down
4 changes: 1 addition & 3 deletions dvc/command/install.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import argparse
import logging

from dvc.command.base import append_doc_link
from dvc.command.base import CmdBase

from dvc.command.base import CmdBase, append_doc_link

logger = logging.getLogger(__name__)

Expand Down
4 changes: 1 addition & 3 deletions dvc/command/lock.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import argparse
import logging

from dvc.command.base import append_doc_link
from dvc.command.base import CmdBase
from dvc.command.base import CmdBase, append_doc_link
from dvc.exceptions import DvcException


logger = logging.getLogger(__name__)


Expand Down
4 changes: 1 addition & 3 deletions dvc/command/ls/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
import logging
import sys

from dvc.command.base import append_doc_link
from dvc.command.base import CmdBaseNoRepo
from dvc.command.base import CmdBaseNoRepo, append_doc_link
from dvc.command.ls.ls_colors import LsColors
from dvc.exceptions import DvcException


logger = logging.getLogger(__name__)


Expand Down
8 changes: 2 additions & 6 deletions dvc/command/metrics.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import argparse
import logging

from dvc.command.base import append_doc_link
from dvc.command.base import CmdBase
from dvc.command.base import fix_subparsers
from dvc.exceptions import BadMetricError
from dvc.exceptions import DvcException

from dvc.command.base import CmdBase, append_doc_link, fix_subparsers
from dvc.exceptions import BadMetricError, DvcException

logger = logging.getLogger(__name__)

Expand Down
4 changes: 1 addition & 3 deletions dvc/command/move.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import argparse
import logging

from dvc.command.base import append_doc_link
from dvc.command.base import CmdBase
from dvc.command.base import CmdBase, append_doc_link
from dvc.exceptions import DvcException


logger = logging.getLogger(__name__)


Expand Down
6 changes: 1 addition & 5 deletions dvc/command/params.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import argparse
import logging

from collections import OrderedDict

from dvc.command.base import append_doc_link
from dvc.command.base import CmdBase
from dvc.command.base import fix_subparsers
from dvc.command.base import CmdBase, append_doc_link, fix_subparsers
from dvc.exceptions import DvcException


logger = logging.getLogger(__name__)


Expand Down
1 change: 0 additions & 1 deletion dvc/command/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from dvc.command.base import CmdBase, append_doc_link, fix_subparsers
from dvc.exceptions import DvcException


logger = logging.getLogger(__name__)


Expand Down
2 changes: 1 addition & 1 deletion dvc/command/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import logging
import os

from dvc.command.base import append_doc_link, CmdBase, fix_subparsers
from dvc.command.base import CmdBase, append_doc_link, fix_subparsers
from dvc.exceptions import DvcException
from dvc.repo.plot.data import WORKSPACE_REVISION_NAME

Expand Down
Loading

0 comments on commit 2bb7257

Please sign in to comment.