Skip to content

Commit

Permalink
Merge pull request #137 from jdufresne/isort
Browse files Browse the repository at this point in the history
  • Loading branch information
pradyunsg authored Nov 26, 2021
2 parents 352ce54 + a72bb8f commit 54ab882
Show file tree
Hide file tree
Showing 22 changed files with 91 additions and 52 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,23 @@ name: Tests
on: [push, pull_request]

jobs:
isort:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2

- name: Install Tox
run: |
pip install tox tox-venv
- name: Run tests
run: tox -e isort

tests:
runs-on: ${{ matrix.os }}
strategy:
Expand Down
1 change: 1 addition & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#
import os
import sys

sys.path.insert(0, os.path.abspath('..'))


Expand Down
4 changes: 2 additions & 2 deletions pep517/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
import os
import shutil

from .compat import FileNotFoundError, toml_load
from .dirtools import mkdir_p, tempdir
from .envbuild import BuildEnvironment
from .wrappers import Pep517HookCaller
from .dirtools import tempdir, mkdir_p
from .compat import FileNotFoundError, toml_load

log = logging.getLogger(__name__)

Expand Down
7 changes: 4 additions & 3 deletions pep517/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
import io
import logging
import os
from os.path import isfile, join as pjoin
import shutil
from subprocess import CalledProcessError
import sys
import tarfile
from tempfile import mkdtemp
import zipfile
from os.path import isfile
from os.path import join as pjoin
from subprocess import CalledProcessError
from tempfile import mkdtemp

from .colorlog import enable_colourful_output
from .compat import TOMLDecodeError, toml_load
Expand Down
3 changes: 1 addition & 2 deletions pep517/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import json
import sys


# Handle reading and writing JSON in UTF-8, on Python 3 and 2.

if sys.version_info[0] >= 3:
Expand Down Expand Up @@ -47,5 +46,5 @@ def toml_load(f):

from toml import TomlDecodeError as TOMLDecodeError # noqa: F401
else:
from tomli import load as toml_load # noqa: F401
from tomli import TOMLDecodeError # noqa: F401
from tomli import load as toml_load # noqa: F401
8 changes: 4 additions & 4 deletions pep517/dirtools.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import os
import io
import contextlib
import tempfile
import shutil
import errno
import io
import os
import shutil
import tempfile
import zipfile


Expand Down
6 changes: 3 additions & 3 deletions pep517/envbuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
"""

import io
import os
import logging
import os
import shutil
from subprocess import check_call
import sys
from subprocess import check_call
from sysconfig import get_paths
from tempfile import mkdtemp

from .compat import toml_load
from .wrappers import Pep517HookCaller, LoggerWrapper
from .wrappers import LoggerWrapper, Pep517HookCaller

log = logging.getLogger(__name__)

Expand Down
3 changes: 2 additions & 1 deletion pep517/in_process/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
The subpackage should stay as empty as possible to avoid shadowing modules that
the backend might import.
"""
from os.path import dirname, abspath, join as pjoin
from contextlib import contextmanager
from os.path import abspath, dirname
from os.path import join as pjoin

try:
import importlib.resources as resources
Expand Down
6 changes: 3 additions & 3 deletions pep517/in_process/_in_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
- control_dir/output.json
- {"return_val": ...}
"""
from glob import glob
from importlib import import_module
import json
import os
import os.path
from os.path import join as pjoin
import re
import shutil
import sys
import traceback
from glob import glob
from importlib import import_module
from os.path import join as pjoin

# This file is run as a script, and `import compat` is not zip-safe, so we
# include write_json() and read_json() from compat.py.
Expand Down
6 changes: 3 additions & 3 deletions pep517/meta.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""Build metadata for a project using PEP 517 hooks.
"""
import argparse
import functools
import logging
import os
import shutil
import functools

try:
import importlib.metadata as imp_meta
Expand All @@ -16,10 +16,10 @@
except ImportError:
from zipp import Path

from .build import compat_system, load_system, validate_system
from .dirtools import dir_to_zipfile, mkdir_p, tempdir
from .envbuild import BuildEnvironment
from .wrappers import Pep517HookCaller, quiet_subprocess_runner
from .dirtools import tempdir, mkdir_p, dir_to_zipfile
from .build import validate_system, load_system, compat_system

log = logging.getLogger(__name__)

Expand Down
9 changes: 5 additions & 4 deletions pep517/wrappers.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import threading
from contextlib import contextmanager
import os
from os.path import abspath, join as pjoin
import shutil
from subprocess import check_call, check_output, STDOUT
import sys
import threading
from contextlib import contextmanager
from os.path import abspath
from os.path import join as pjoin
from subprocess import STDOUT, check_call, check_output
from tempfile import mkdtemp

from . import compat
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ classifiers = [
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
]

[tool.isort]
profile = "black"
4 changes: 2 additions & 2 deletions tests/samples/buildsys_pkgs/buildsys.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
Don't use this for any real code.
"""

from glob import glob
from os.path import join as pjoin
import shutil
import tarfile
from glob import glob
from os.path import join as pjoin
from zipfile import ZipFile


Expand Down
2 changes: 1 addition & 1 deletion tests/samples/buildsys_pkgs/buildsys_minimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
Don't use this for any real code.
"""
import tarfile
from glob import glob
from os.path import join as pjoin
import tarfile
from zipfile import ZipFile


Expand Down
1 change: 0 additions & 1 deletion tests/samples/buildsys_pkgs/buildsys_minimal_editable.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from buildsys_minimal import build_sdist, build_wheel # noqa


build_editable = build_wheel
5 changes: 3 additions & 2 deletions tests/samples/test-for-issue-104/setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import json
import sys
from os import environ, listdir, path

from setuptools import setup
from os import path, environ, listdir
import json

children = listdir(sys.path[0])
out = path.join(environ['PEP517_ISSUE104_OUTDIR'], 'out.json')
Expand Down
23 changes: 14 additions & 9 deletions tests/test_call_hooks.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
import io
import json
import os
from os.path import dirname, abspath, join as pjoin
import sys
import tarfile
from testpath import modified_env, assert_isfile
from testpath.tempdir import TemporaryDirectory, TemporaryWorkingDirectory
import pytest
import zipfile
import sys
import json
from os.path import abspath, dirname
from os.path import join as pjoin

import pytest
from testpath import assert_isfile, modified_env
from testpath.tempdir import TemporaryDirectory, TemporaryWorkingDirectory

try:
from mock import Mock # Prefer the backport below python 3.6
except ImportError:
from unittest.mock import Mock

from pep517.compat import toml_load
from pep517.wrappers import Pep517HookCaller, default_subprocess_runner
from pep517.wrappers import UnsupportedOperation, BackendUnavailable

from pep517.wrappers import (
BackendUnavailable,
Pep517HookCaller,
UnsupportedOperation,
default_subprocess_runner,
)

if sys.version_info[0] == 2:
FileNotFoundError = IOError
Expand Down
12 changes: 8 additions & 4 deletions tests/test_envbuild.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
from os.path import dirname, abspath, join as pjoin
import tarfile
from testpath import modified_env, assert_isfile
from os.path import abspath, dirname
from os.path import join as pjoin

from testpath import assert_isfile, modified_env
from testpath.tempdir import TemporaryDirectory

try:
from unittest.mock import patch, call
from unittest.mock import call, patch
except ImportError:
from mock import patch, call # Python 2 fallback

import zipfile

from pep517.envbuild import build_sdist, build_wheel, BuildEnvironment
from pep517.envbuild import BuildEnvironment, build_sdist, build_wheel

SAMPLES_DIR = pjoin(dirname(abspath(__file__)), 'samples')
BUILDSYS_PKGS = pjoin(SAMPLES_DIR, 'buildsys_pkgs')
Expand Down
6 changes: 4 additions & 2 deletions tests/test_hook_fallbacks.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import io
from os.path import dirname, abspath, join as pjoin
from os.path import abspath, dirname
from os.path import join as pjoin

import pytest
from testpath import modified_env, assert_isfile
from testpath import assert_isfile, modified_env
from testpath.tempdir import TemporaryDirectory

from pep517.compat import toml_load
Expand Down
8 changes: 5 additions & 3 deletions tests/test_inplace_hooks.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import io
from os.path import dirname, abspath, join as pjoin
from testpath import modified_env
from os.path import abspath, dirname
from os.path import join as pjoin

import pytest
from testpath import modified_env

from pep517.compat import toml_load
from pep517.wrappers import Pep517HookCaller, BackendInvalid
from pep517.wrappers import BackendInvalid, Pep517HookCaller

SAMPLES_DIR = pjoin(dirname(abspath(__file__)), 'samples')
BUILDSYS_PKGS = pjoin(SAMPLES_DIR, 'buildsys_pkgs')
Expand Down
3 changes: 1 addition & 2 deletions tests/test_meta.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from __future__ import unicode_literals, absolute_import, division
from __future__ import absolute_import, division, unicode_literals

import re

import pytest

from pep517 import meta


pep517_needs_python_3 = pytest.mark.xfail(
'sys.version_info < (3,)',
reason="pep517 cannot be built on Python 2",
Expand Down
6 changes: 5 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
[tox]
envlist = py27, py34, py35, py36, py37, py38, py39, py310, pypy, pypy3
envlist = py27, py34, py35, py36, py37, py38, py39, py310, pypy, pypy3, isort
skipsdist = true

[testenv]
deps = -rdev-requirements.txt
commands = pytest []

[testenv:isort]
deps = isort
commands = python -m isort --check --diff {toxinidir}

[testenv:release]
skip_install = True
deps =
Expand Down

0 comments on commit 54ab882

Please sign in to comment.