Skip to content

Commit

Permalink
Use isort to keep imports sorted
Browse files Browse the repository at this point in the history
Disable hacking H301 and H306 which aren't compatible with isort.
  • Loading branch information
philpep committed Sep 18, 2021
1 parent 73e0a41 commit 9474485
Show file tree
Hide file tree
Showing 14 changed files with 23 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[flake8]
extend-ignore = E203, E266, E501
extend-ignore = E203, E266, E501, H301, H306
# line length is intentionally set to 80 here because black uses Bugbear
# See https://github.com/psf/black/blob/master/docs/the_black_code_style.md#line-length for more details
max-line-length = 80
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,9 @@ exclude = '''
)/
)
'''

[tool.isort]
profile = "black"
multi_line_output = 3

known_first_party = ["testinfra"]
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
def local_scheme(version):
"""Generate a PEP440 compatible version if PEP440_VERSION is enabled"""
import os

import setuptools_scm.version # only present during setup time

return (
Expand Down
3 changes: 1 addition & 2 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@
import pytest

import testinfra
from testinfra.backend.base import BaseBackend
from testinfra.backend import parse_hostspec

from testinfra.backend.base import BaseBackend

BASETESTDIR = os.path.abspath(os.path.dirname(__file__))
BASEDIR = os.path.abspath(os.path.join(BASETESTDIR, os.pardir))
Expand Down
6 changes: 3 additions & 3 deletions test/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@

import operator
import os
import pytest
import tempfile

import pytest

import testinfra
import testinfra.backend
from testinfra.backend.base import BaseBackend
from testinfra.backend.base import HostSpec
from testinfra.backend.base import BaseBackend, HostSpec
from testinfra.backend.winrm import _quote
from testinfra.utils.ansible_runner import AnsibleRunner

Expand Down
7 changes: 2 additions & 5 deletions test/test_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,11 @@
import crypt
import datetime
import os
import pytest
import re
import time
from ipaddress import IPv4Address, IPv6Address, ip_address

from ipaddress import ip_address
from ipaddress import IPv4Address
from ipaddress import IPv6Address

import pytest

from testinfra.modules.socket import parse_socketspec

Expand Down
3 changes: 1 addition & 2 deletions testinfra/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from testinfra.host import get_host
from testinfra.host import get_hosts
from testinfra.host import get_host, get_hosts

__all__ = ["get_host", "get_hosts"]
1 change: 0 additions & 1 deletion testinfra/backend/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import os
import urllib.parse


BACKENDS = {
"local": "testinfra.backend.local.LocalBackend",
"ssh": "testinfra.backend.ssh.SshBackend",
Expand Down
1 change: 1 addition & 0 deletions testinfra/backend/winrm.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# limitations under the License.

import re

from testinfra.backend import base

try:
Expand Down
4 changes: 1 addition & 3 deletions testinfra/modules/socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
# limitations under the License.

import socket
from typing import List
from typing import Optional
from typing import Tuple
from typing import List, Optional, Tuple

from testinfra.modules.base import Module
from testinfra.utils import cached_property
Expand Down
3 changes: 2 additions & 1 deletion testinfra/modules/supervisor.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from testinfra.modules.base import Module
from typing import NoReturn

from testinfra.modules.base import Module

STATUS = [
"STOPPED",
"STARTING",
Expand Down
1 change: 1 addition & 0 deletions testinfra/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import time

import pytest

import testinfra
import testinfra.host
import testinfra.modules
Expand Down
7 changes: 1 addition & 6 deletions testinfra/utils/ansible_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,11 @@
import json
import os
import tempfile
from typing import Dict
from typing import List
from typing import Optional
from typing import Union

from typing import Dict, List, Optional, Union

import testinfra
from testinfra.utils import cached_property


__all__ = ["AnsibleRunner"]

local = testinfra.get_host("local://")
Expand Down
2 changes: 2 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ deps=
flake8-pep3101
flake8-print
black
isort
commands=
black --check --diff {toxinidir}
isort --check --diff testinfra test setup.py
flake8 {posargs}

[testenv:docs]
Expand Down

0 comments on commit 9474485

Please sign in to comment.