Unverified Commit 9df2f1ff authored by Aaron Gokaslan's avatar Aaron Gokaslan Committed by GitHub
Browse files

maint(precommit): Apply isort (#3195)

* Apply isort

* Tweak isort config

* Add env.py as a known_first_party

* Add one missing known first party

* Make config compat with older isort versions

* Add another comment

* Revert pyproject setting
parent d6841f60
...@@ -35,6 +35,11 @@ repos: ...@@ -35,6 +35,11 @@ repos:
hooks: hooks:
- id: pyupgrade - id: pyupgrade
- repo: https://github.com/PyCQA/isort
rev: 5.9.3
hooks:
- id: isort
# Black, the code formatter, natively supports pre-commit # Black, the code formatter, natively supports pre-commit
- repo: https://github.com/psf/black - repo: https://github.com/psf/black
rev: 21.7b0 rev: 21.7b0
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import random import datetime as dt
import os import os
import random
import time import time
import datetime as dt
nfns = 4 # Functions per class nfns = 4 # Functions per class
nargs = 4 # Arguments per function nargs = 4 # Arguments per function
......
...@@ -13,12 +13,12 @@ ...@@ -13,12 +13,12 @@
# All configuration values have a default; values that are commented out # All configuration values have a default; values that are commented out
# serve to show the default. # serve to show the default.
import sys
import os import os
import re
import shlex import shlex
import subprocess import subprocess
import sys
from pathlib import Path from pathlib import Path
import re
DIR = Path(__file__).parent.resolve() DIR = Path(__file__).parent.resolve()
......
import nox import nox
nox.options.sessions = ["lint", "tests", "tests_packaging"] nox.options.sessions = ["lint", "tests", "tests_packaging"]
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from ._version import version_info, __version__ from ._version import __version__, version_info
from .commands import get_include, get_cmake_dir from .commands import get_cmake_dir, get_include
__all__ = ( __all__ = (
"version_info", "version_info",
......
...@@ -5,7 +5,7 @@ import argparse ...@@ -5,7 +5,7 @@ import argparse
import sys import sys
import sysconfig import sysconfig
from .commands import get_include, get_cmake_dir from .commands import get_cmake_dir, get_include
def print_includes(): def print_includes():
......
from typing import Union, Tuple from typing import Tuple, Union
def _to_int(s: str) -> Union[int, str]: ... def _to_int(s: str) -> Union[int, str]: ...
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import os import os
DIR = os.path.abspath(os.path.dirname(__file__)) DIR = os.path.abspath(os.path.dirname(__file__))
......
...@@ -41,23 +41,23 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -41,23 +41,23 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import contextlib import contextlib
import os import os
import platform
import shutil import shutil
import sys import sys
import sysconfig
import tempfile import tempfile
import threading import threading
import platform
import warnings import warnings
import sysconfig
try: try:
from setuptools.command.build_ext import build_ext as _build_ext
from setuptools import Extension as _Extension from setuptools import Extension as _Extension
from setuptools.command.build_ext import build_ext as _build_ext
except ImportError: except ImportError:
from distutils.command.build_ext import build_ext as _build_ext from distutils.command.build_ext import build_ext as _build_ext
from distutils.extension import Extension as _Extension from distutils.extension import Extension as _Extension
import distutils.errors
import distutils.ccompiler import distutils.ccompiler
import distutils.errors
WIN = sys.platform.startswith("win32") and "mingw" not in sysconfig.get_platform() WIN = sys.platform.startswith("win32") and "mingw" not in sysconfig.get_platform()
PY2 = sys.version_info[0] < 3 PY2 = sys.version_info[0] < 3
......
# IMPORTANT: Should stay in sync with setup_helpers.py (mostly checked by CI / # IMPORTANT: Should stay in sync with setup_helpers.py (mostly checked by CI /
# pre-commit). # pre-commit).
from typing import Any, Callable, Dict, Iterator, List, Optional, Type, TypeVar, Union import contextlib
from types import TracebackType import distutils.ccompiler
from distutils.command.build_ext import build_ext as _build_ext # type: ignore from distutils.command.build_ext import build_ext as _build_ext # type: ignore
from distutils.extension import Extension as _Extension from distutils.extension import Extension as _Extension
import distutils.ccompiler from types import TracebackType
import contextlib from typing import Any, Callable, Dict, Iterator, List, Optional, Type, TypeVar, Union
WIN: bool WIN: bool
PY2: bool PY2: bool
......
...@@ -15,6 +15,12 @@ ignore = [ ...@@ -15,6 +15,12 @@ ignore = [
"noxfile.py", "noxfile.py",
] ]
[tool.isort]
# Needs the compiled .so modules and env.py from tests
known_first_party = "env,pybind11_cross_module_tests,pybind11_tests,"
# For black compatibility
profile = "black"
[tool.mypy] [tool.mypy]
files = "pybind11" files = "pybind11"
python_version = "2.7" python_version = "2.7"
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
# Setup script for PyPI; use CMakeFile.txt to build extension modules # Setup script for PyPI; use CMakeFile.txt to build extension modules
import contextlib import contextlib
import io
import os import os
import re import re
import shutil import shutil
...@@ -11,7 +12,6 @@ import string ...@@ -11,7 +12,6 @@ import string
import subprocess import subprocess
import sys import sys
import tempfile import tempfile
import io
import setuptools.command.sdist import setuptools.command.sdist
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import os import os
import sys
import subprocess import subprocess
import sys
from textwrap import dedent from textwrap import dedent
import pytest import pytest
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import ctypes
import io import io
import struct import struct
import ctypes
import pytest import pytest
import env # noqa: F401 import env # noqa: F401
from pybind11_tests import buffers as m
from pybind11_tests import ConstructorStats from pybind11_tests import ConstructorStats
from pybind11_tests import buffers as m
np = pytest.importorskip("numpy") np = pytest.importorskip("numpy")
......
...@@ -2,9 +2,8 @@ ...@@ -2,9 +2,8 @@
import pytest import pytest
import env # noqa: F401 import env # noqa: F401
from pybind11_tests import IncType, UserType
from pybind11_tests import builtin_casters as m from pybind11_tests import builtin_casters as m
from pybind11_tests import UserType, IncType
def test_simple_string(): def test_simple_string():
......
...@@ -2,9 +2,8 @@ ...@@ -2,9 +2,8 @@
import pytest import pytest
import env # noqa: F401 import env # noqa: F401
from pybind11_tests import call_policies as m
from pybind11_tests import ConstructorStats from pybind11_tests import ConstructorStats
from pybind11_tests import call_policies as m
@pytest.mark.xfail("env.PYPY", reason="sometimes comes out 1 off on PyPy", strict=False) @pytest.mark.xfail("env.PYPY", reason="sometimes comes out 1 off on PyPy", strict=False)
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import pytest
from pybind11_tests import callbacks as m
from threading import Thread
import time import time
from threading import Thread
import pytest
import env # NOQA: F401 import env # NOQA: F401
from pybind11_tests import callbacks as m
def test_callbacks(): def test_callbacks():
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from pybind11_tests import chrono as m
import datetime import datetime
import pytest import pytest
import env # noqa: F401 import env # noqa: F401
from pybind11_tests import chrono as m
def test_chrono_system_clock(): def test_chrono_system_clock():
......
...@@ -2,9 +2,8 @@ ...@@ -2,9 +2,8 @@
import pytest import pytest
import env # noqa: F401 import env # noqa: F401
from pybind11_tests import ConstructorStats, UserType
from pybind11_tests import class_ as m from pybind11_tests import class_ as m
from pybind11_tests import UserType, ConstructorStats
def test_repr(): def test_repr():
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import sys import sys
import test_cmake_build import test_cmake_build
assert test_cmake_build.add(1, 2) == 3 assert test_cmake_build.add(1, 2) == 3
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment