Automatically sort Python imports in code.

This commit is contained in:
Dan Helfman 2019-05-14 17:02:37 +00:00 committed by Gitea
commit 99522234ea
37 changed files with 56 additions and 54 deletions

View file

@ -5,7 +5,6 @@ import subprocess
from borgmatic.borg import extract from borgmatic.borg import extract
from borgmatic.logger import get_logger from borgmatic.logger import get_logger
DEFAULT_CHECKS = ('repository', 'archives') DEFAULT_CHECKS = ('repository', 'archives')
DEFAULT_PREFIX = '{hostname}-' DEFAULT_PREFIX = '{hostname}-'

View file

@ -7,7 +7,6 @@ import tempfile
from borgmatic.borg.execute import execute_command from borgmatic.borg.execute import execute_command
from borgmatic.logger import get_logger from borgmatic.logger import get_logger
logger = get_logger(__name__) logger = get_logger(__name__)

View file

@ -2,7 +2,6 @@ import subprocess
from borgmatic.logger import get_logger from borgmatic.logger import get_logger
logger = get_logger(__name__) logger = get_logger(__name__)

View file

@ -1,10 +1,9 @@
import logging import logging
import sys
import subprocess import subprocess
import sys
from borgmatic.logger import get_logger from borgmatic.logger import get_logger
logger = get_logger(__name__) logger = get_logger(__name__)

View file

@ -3,7 +3,6 @@ import logging
from borgmatic.borg.execute import execute_command from borgmatic.borg.execute import execute_command
from borgmatic.logger import get_logger from borgmatic.logger import get_logger
logger = get_logger(__name__) logger = get_logger(__name__)

View file

@ -3,7 +3,6 @@ import logging
from borgmatic.borg.execute import execute_command from borgmatic.borg.execute import execute_command
from borgmatic.logger import get_logger from borgmatic.logger import get_logger
logger = get_logger(__name__) logger = get_logger(__name__)

View file

@ -3,7 +3,6 @@ import subprocess
from borgmatic.logger import get_logger from borgmatic.logger import get_logger
logger = get_logger(__name__) logger = get_logger(__name__)

View file

@ -1,31 +1,28 @@
from argparse import ArgumentParser
import collections import collections
import colorama
import json import json
import logging import logging
import os import os
from subprocess import CalledProcessError
import sys import sys
from argparse import ArgumentParser
from subprocess import CalledProcessError
import colorama
import pkg_resources import pkg_resources
from borgmatic.borg import ( from borgmatic.borg import check as borg_check
check as borg_check, from borgmatic.borg import create as borg_create
create as borg_create, from borgmatic.borg import environment as borg_environment
environment as borg_environment, from borgmatic.borg import extract as borg_extract
prune as borg_prune, from borgmatic.borg import info as borg_info
extract as borg_extract, from borgmatic.borg import init as borg_init
list as borg_list, from borgmatic.borg import list as borg_list
info as borg_info, from borgmatic.borg import prune as borg_prune
init as borg_init,
)
from borgmatic.commands import hook from borgmatic.commands import hook
from borgmatic.config import checks, collect, convert, validate from borgmatic.config import checks, collect, convert, validate
from borgmatic.logger import should_do_markup, get_logger from borgmatic.logger import get_logger, should_do_markup
from borgmatic.signals import configure_signals from borgmatic.signals import configure_signals
from borgmatic.verbosity import verbosity_to_log_level from borgmatic.verbosity import verbosity_to_log_level
logger = get_logger(__name__) logger = get_logger(__name__)
LEGACY_CONFIG_PATH = '/etc/borgmatic/config' LEGACY_CONFIG_PATH = '/etc/borgmatic/config'

View file

@ -1,13 +1,12 @@
from argparse import ArgumentParser
import os import os
import sys import sys
import textwrap import textwrap
from argparse import ArgumentParser
from ruamel import yaml from ruamel import yaml
from borgmatic.config import convert, generate, legacy, validate from borgmatic.config import convert, generate, legacy, validate
DEFAULT_SOURCE_CONFIG_FILENAME = '/etc/borgmatic/config' DEFAULT_SOURCE_CONFIG_FILENAME = '/etc/borgmatic/config'
DEFAULT_SOURCE_EXCLUDES_FILENAME = '/etc/borgmatic/excludes' DEFAULT_SOURCE_EXCLUDES_FILENAME = '/etc/borgmatic/excludes'
DEFAULT_DESTINATION_CONFIG_FILENAME = '/etc/borgmatic/config.yaml' DEFAULT_DESTINATION_CONFIG_FILENAME = '/etc/borgmatic/config.yaml'

View file

@ -1,9 +1,8 @@
from argparse import ArgumentParser
import sys import sys
from argparse import ArgumentParser
from borgmatic.config import generate, validate from borgmatic.config import generate, validate
DEFAULT_DESTINATION_CONFIG_FILENAME = '/etc/borgmatic/config.yaml' DEFAULT_DESTINATION_CONFIG_FILENAME = '/etc/borgmatic/config.yaml'

View file

@ -2,7 +2,6 @@ import subprocess
from borgmatic.logger import get_logger from borgmatic.logger import get_logger
logger = get_logger(__name__) logger = get_logger(__name__)

View file

@ -1,6 +1,6 @@
from argparse import ArgumentParser
import sys
import logging import logging
import sys
from argparse import ArgumentParser
from borgmatic.config import collect, validate from borgmatic.config import collect, validate
from borgmatic.logger import get_logger from borgmatic.logger import get_logger

View file

@ -2,7 +2,6 @@ import os
from ruamel import yaml from ruamel import yaml
INDENT = 4 INDENT = 4

View file

@ -1,7 +1,6 @@
from collections import OrderedDict, namedtuple from collections import OrderedDict, namedtuple
from configparser import RawConfigParser from configparser import RawConfigParser
Section_format = namedtuple('Section_format', ('name', 'options')) Section_format = namedtuple('Section_format', ('name', 'options'))
Config_option = namedtuple('Config_option', ('name', 'value_type', 'required')) Config_option = namedtuple('Config_option', ('name', 'value_type', 'required'))

View file

@ -4,7 +4,6 @@ import ruamel.yaml
from borgmatic.logger import get_logger from borgmatic.logger import get_logger
logger = get_logger(__name__) logger = get_logger(__name__)

View file

@ -8,7 +8,6 @@ import ruamel.yaml
from borgmatic.config import load from borgmatic.config import load
from borgmatic.logger import get_logger from borgmatic.logger import get_logger
logger = get_logger(__name__) logger = get_logger(__name__)

View file

@ -1,6 +1,5 @@
import logging import logging
VERBOSITY_WARNING = 0 VERBOSITY_WARNING = 0
VERBOSITY_SOME = 1 VERBOSITY_SOME = 1
VERBOSITY_LOTS = 2 VERBOSITY_LOTS = 2

3
scripts/isort Executable file
View file

@ -0,0 +1,3 @@
#!/usr/bin/env sh
isort --recursive --check-only --settings-path setup.cfg .

View file

@ -8,3 +8,11 @@ addopts = --cov-report term-missing:skip-covered --cov=borgmatic --ignore=tests/
[flake8] [flake8]
ignore = E501,W503 ignore = E501,W503
exclude = *.*/* exclude = *.*/*
[tool:isort]
force_single_line = False
include_trailing_comma = True
known_first_party = borgmatic
line_length = 100
multi_line_output = 3
skip = .tox

View file

@ -1,5 +1,4 @@
from setuptools import setup, find_packages from setuptools import find_packages, setup
VERSION = '1.3.4.dev0' VERSION = '1.3.4.dev0'

View file

@ -8,6 +8,7 @@ coverage==4.5.1
docopt==0.6.2 docopt==0.6.2
flake8==3.5.0 flake8==3.5.0
flexmock==0.10.2 flexmock==0.10.2
isort==4.3.19
mccabe==0.6.1 mccabe==0.6.1
more-itertools==4.3.0 more-itertools==4.3.0
pluggy==0.7.1 pluggy==0.7.1

View file

@ -1,7 +1,7 @@
import subprocess import subprocess
from flexmock import flexmock
import pytest import pytest
from flexmock import flexmock
from borgmatic.commands import borgmatic as module from borgmatic.commands import borgmatic as module

View file

@ -1,7 +1,7 @@
import os import os
from flexmock import flexmock
import pytest import pytest
from flexmock import flexmock
from borgmatic.commands import convert_config as module from borgmatic.commands import convert_config as module

View file

@ -1,9 +1,9 @@
from io import StringIO
import os import os
import sys import sys
from io import StringIO
from flexmock import flexmock
import pytest import pytest
from flexmock import flexmock
from borgmatic.config import generate as module from borgmatic.config import generate as module

View file

@ -1,7 +1,6 @@
from io import StringIO
from collections import OrderedDict
import string import string
from collections import OrderedDict
from io import StringIO
from borgmatic.config import legacy as module from borgmatic.config import legacy as module

View file

@ -2,8 +2,8 @@ import io
import string import string
import sys import sys
from flexmock import flexmock
import pytest import pytest
from flexmock import flexmock
from borgmatic.config import validate as module from borgmatic.config import validate as module

View file

@ -1,11 +1,12 @@
from subprocess import STDOUT
import logging import logging
import sys import sys
from subprocess import STDOUT
from flexmock import flexmock
import pytest import pytest
from flexmock import flexmock
from borgmatic.borg import check as module from borgmatic.borg import check as module
from ..test_verbosity import insert_logging_mock from ..test_verbosity import insert_logging_mock

View file

@ -3,6 +3,7 @@ import logging
from flexmock import flexmock from flexmock import flexmock
from borgmatic.borg import create as module from borgmatic.borg import create as module
from ..test_verbosity import insert_logging_mock from ..test_verbosity import insert_logging_mock

View file

@ -1,4 +1,5 @@
from flexmock import flexmock from flexmock import flexmock
from borgmatic.borg import execute as module from borgmatic.borg import execute as module

View file

@ -4,6 +4,7 @@ import sys
from flexmock import flexmock from flexmock import flexmock
from borgmatic.borg import extract as module from borgmatic.borg import extract as module
from ..test_verbosity import insert_logging_mock from ..test_verbosity import insert_logging_mock

View file

@ -3,8 +3,8 @@ import logging
from flexmock import flexmock from flexmock import flexmock
from borgmatic.borg import info as module from borgmatic.borg import info as module
from ..test_verbosity import insert_logging_mock
from ..test_verbosity import insert_logging_mock
INFO_COMMAND = ('borg', 'info', 'repo') INFO_COMMAND = ('borg', 'info', 'repo')

View file

@ -3,8 +3,8 @@ import logging
from flexmock import flexmock from flexmock import flexmock
from borgmatic.borg import init as module from borgmatic.borg import init as module
from ..test_verbosity import insert_logging_mock
from ..test_verbosity import insert_logging_mock
INFO_REPOSITORY_EXISTS_RESPONSE_CODE = 0 INFO_REPOSITORY_EXISTS_RESPONSE_CODE = 0
INFO_REPOSITORY_NOT_FOUND_RESPONSE_CODE = 2 INFO_REPOSITORY_NOT_FOUND_RESPONSE_CODE = 2

View file

@ -3,8 +3,8 @@ import logging
from flexmock import flexmock from flexmock import flexmock
from borgmatic.borg import list as module from borgmatic.borg import list as module
from ..test_verbosity import insert_logging_mock
from ..test_verbosity import insert_logging_mock
LIST_COMMAND = ('borg', 'list', 'repo') LIST_COMMAND = ('borg', 'list', 'repo')

View file

@ -4,6 +4,7 @@ from collections import OrderedDict
from flexmock import flexmock from flexmock import flexmock
from borgmatic.borg import prune as module from borgmatic.borg import prune as module
from ..test_verbosity import insert_logging_mock from ..test_verbosity import insert_logging_mock

View file

@ -1,12 +1,11 @@
from collections import defaultdict, OrderedDict, namedtuple
import os import os
from collections import OrderedDict, defaultdict, namedtuple
from flexmock import flexmock
import pytest import pytest
from flexmock import flexmock
from borgmatic.config import convert as module from borgmatic.config import convert as module
Parsed_config = namedtuple('Parsed_config', ('location', 'storage', 'retention', 'consistency')) Parsed_config = namedtuple('Parsed_config', ('location', 'storage', 'retention', 'consistency'))

View file

@ -1,7 +1,7 @@
from collections import OrderedDict from collections import OrderedDict
from flexmock import flexmock
import pytest import pytest
from flexmock import flexmock
from borgmatic.config import legacy as module from borgmatic.config import legacy as module

View file

@ -13,6 +13,7 @@ install_command =
commands = commands =
pytest pytest
sh scripts/black sh scripts/black
sh scripts/isort
flake8 . flake8 .
[testenv:black] [testenv:black]
@ -24,3 +25,8 @@ commands =
deps = -rtest_requirements.txt deps = -rtest_requirements.txt
commands = commands =
pytest tests/end-to-end pytest tests/end-to-end
[testenv:isort]
deps = {[testenv]deps}
commands =
isort {posargs:--recursive} --settings-path setup.cfg .