mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-21 20:55:11 +00:00
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
This commit is contained in:
parent
d6841f60cc
commit
9df2f1ff13
@ -35,6 +35,11 @@ repos:
|
||||
hooks:
|
||||
- id: pyupgrade
|
||||
|
||||
- repo: https://github.com/PyCQA/isort
|
||||
rev: 5.9.3
|
||||
hooks:
|
||||
- id: isort
|
||||
|
||||
# Black, the code formatter, natively supports pre-commit
|
||||
- repo: https://github.com/psf/black
|
||||
rev: 21.7b0
|
||||
|
@ -1,8 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import random
|
||||
import os
|
||||
import time
|
||||
import datetime as dt
|
||||
import os
|
||||
import random
|
||||
import time
|
||||
|
||||
nfns = 4 # Functions per class
|
||||
nargs = 4 # Arguments per function
|
||||
|
@ -13,12 +13,12 @@
|
||||
# All configuration values have a default; values that are commented out
|
||||
# serve to show the default.
|
||||
|
||||
import sys
|
||||
import os
|
||||
import re
|
||||
import shlex
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
import re
|
||||
|
||||
DIR = Path(__file__).parent.resolve()
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
import nox
|
||||
|
||||
|
||||
nox.options.sessions = ["lint", "tests", "tests_packaging"]
|
||||
|
||||
|
||||
|
@ -1,8 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from ._version import version_info, __version__
|
||||
from .commands import get_include, get_cmake_dir
|
||||
|
||||
from ._version import __version__, version_info
|
||||
from .commands import get_cmake_dir, get_include
|
||||
|
||||
__all__ = (
|
||||
"version_info",
|
||||
|
@ -5,7 +5,7 @@ import argparse
|
||||
import sys
|
||||
import sysconfig
|
||||
|
||||
from .commands import get_include, get_cmake_dir
|
||||
from .commands import get_cmake_dir, get_include
|
||||
|
||||
|
||||
def print_includes():
|
||||
|
@ -1,4 +1,4 @@
|
||||
from typing import Union, Tuple
|
||||
from typing import Tuple, Union
|
||||
|
||||
def _to_int(s: str) -> Union[int, str]: ...
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import os
|
||||
|
||||
|
||||
DIR = os.path.abspath(os.path.dirname(__file__))
|
||||
|
||||
|
||||
|
@ -41,23 +41,23 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import contextlib
|
||||
import os
|
||||
import platform
|
||||
import shutil
|
||||
import sys
|
||||
import sysconfig
|
||||
import tempfile
|
||||
import threading
|
||||
import platform
|
||||
import warnings
|
||||
import sysconfig
|
||||
|
||||
try:
|
||||
from setuptools.command.build_ext import build_ext as _build_ext
|
||||
from setuptools import Extension as _Extension
|
||||
from setuptools.command.build_ext import build_ext as _build_ext
|
||||
except ImportError:
|
||||
from distutils.command.build_ext import build_ext as _build_ext
|
||||
from distutils.extension import Extension as _Extension
|
||||
|
||||
import distutils.errors
|
||||
import distutils.ccompiler
|
||||
import distutils.errors
|
||||
|
||||
WIN = sys.platform.startswith("win32") and "mingw" not in sysconfig.get_platform()
|
||||
PY2 = sys.version_info[0] < 3
|
||||
|
@ -1,13 +1,12 @@
|
||||
# IMPORTANT: Should stay in sync with setup_helpers.py (mostly checked by CI /
|
||||
# pre-commit).
|
||||
|
||||
from typing import Any, Callable, Dict, Iterator, List, Optional, Type, TypeVar, Union
|
||||
from types import TracebackType
|
||||
|
||||
import contextlib
|
||||
import distutils.ccompiler
|
||||
from distutils.command.build_ext import build_ext as _build_ext # type: ignore
|
||||
from distutils.extension import Extension as _Extension
|
||||
import distutils.ccompiler
|
||||
import contextlib
|
||||
from types import TracebackType
|
||||
from typing import Any, Callable, Dict, Iterator, List, Optional, Type, TypeVar, Union
|
||||
|
||||
WIN: bool
|
||||
PY2: bool
|
||||
|
@ -15,6 +15,12 @@ ignore = [
|
||||
"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]
|
||||
files = "pybind11"
|
||||
python_version = "2.7"
|
||||
|
2
setup.py
2
setup.py
@ -4,6 +4,7 @@
|
||||
# Setup script for PyPI; use CMakeFile.txt to build extension modules
|
||||
|
||||
import contextlib
|
||||
import io
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
@ -11,7 +12,6 @@ import string
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import io
|
||||
|
||||
import setuptools.command.sdist
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
import sys
|
||||
from textwrap import dedent
|
||||
|
||||
import pytest
|
||||
|
@ -1,14 +1,13 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import ctypes
|
||||
import io
|
||||
import struct
|
||||
import ctypes
|
||||
|
||||
import pytest
|
||||
|
||||
import env # noqa: F401
|
||||
|
||||
from pybind11_tests import buffers as m
|
||||
from pybind11_tests import ConstructorStats
|
||||
from pybind11_tests import buffers as m
|
||||
|
||||
np = pytest.importorskip("numpy")
|
||||
|
||||
|
@ -2,9 +2,8 @@
|
||||
import pytest
|
||||
|
||||
import env # noqa: F401
|
||||
|
||||
from pybind11_tests import IncType, UserType
|
||||
from pybind11_tests import builtin_casters as m
|
||||
from pybind11_tests import UserType, IncType
|
||||
|
||||
|
||||
def test_simple_string():
|
||||
|
@ -2,9 +2,8 @@
|
||||
import pytest
|
||||
|
||||
import env # noqa: F401
|
||||
|
||||
from pybind11_tests import call_policies as m
|
||||
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)
|
||||
|
@ -1,9 +1,11 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import pytest
|
||||
from pybind11_tests import callbacks as m
|
||||
from threading import Thread
|
||||
import time
|
||||
from threading import Thread
|
||||
|
||||
import pytest
|
||||
|
||||
import env # NOQA: F401
|
||||
from pybind11_tests import callbacks as m
|
||||
|
||||
|
||||
def test_callbacks():
|
||||
|
@ -1,9 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from pybind11_tests import chrono as m
|
||||
import datetime
|
||||
|
||||
import pytest
|
||||
|
||||
import env # noqa: F401
|
||||
from pybind11_tests import chrono as m
|
||||
|
||||
|
||||
def test_chrono_system_clock():
|
||||
|
@ -2,9 +2,8 @@
|
||||
import pytest
|
||||
|
||||
import env # noqa: F401
|
||||
|
||||
from pybind11_tests import ConstructorStats, UserType
|
||||
from pybind11_tests import class_ as m
|
||||
from pybind11_tests import UserType, ConstructorStats
|
||||
|
||||
|
||||
def test_repr():
|
||||
|
@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import sys
|
||||
|
||||
import test_cmake_build
|
||||
|
||||
assert test_cmake_build.add(1, 2) == 3
|
||||
|
@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import pytest
|
||||
|
||||
from pybind11_tests import copy_move_policies as m
|
||||
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import pytest
|
||||
|
||||
from pybind11_tests import custom_type_casters as m
|
||||
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import pytest
|
||||
|
||||
from pybind11_tests import ConstructorStats
|
||||
|
||||
np = pytest.importorskip("numpy")
|
||||
|
@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import pytest
|
||||
|
||||
from pybind11_tests import enums as m
|
||||
|
||||
|
||||
|
@ -4,7 +4,6 @@ import os
|
||||
import pytest
|
||||
|
||||
import env # noqa: F401
|
||||
|
||||
from pybind11_tests import eval_ as m
|
||||
|
||||
|
||||
|
@ -4,9 +4,8 @@ import sys
|
||||
import pytest
|
||||
|
||||
import env # noqa: F401
|
||||
|
||||
from pybind11_tests import exceptions as m
|
||||
import pybind11_cross_module_tests as cm
|
||||
from pybind11_tests import exceptions as m
|
||||
|
||||
|
||||
def test_std_exception(msg):
|
||||
|
@ -1,12 +1,12 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import pytest
|
||||
import re
|
||||
|
||||
import env # noqa: F401
|
||||
import pytest
|
||||
|
||||
import env # noqa: F401
|
||||
from pybind11_tests import ConstructorStats
|
||||
from pybind11_tests import factory_constructors as m
|
||||
from pybind11_tests.factory_constructors import tag
|
||||
from pybind11_tests import ConstructorStats
|
||||
|
||||
|
||||
def test_init_factory_basic():
|
||||
|
@ -1,9 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from pybind11_tests import iostream as m
|
||||
import sys
|
||||
|
||||
from contextlib import contextmanager
|
||||
|
||||
from pybind11_tests import iostream as m
|
||||
|
||||
try:
|
||||
# Python 3
|
||||
from io import StringIO
|
||||
|
@ -2,7 +2,6 @@
|
||||
import pytest
|
||||
|
||||
import env # noqa: F401
|
||||
|
||||
from pybind11_tests import kwargs_and_defaults as m
|
||||
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
import pytest
|
||||
|
||||
import env # noqa: F401
|
||||
|
||||
from pybind11_tests import local_bindings as m
|
||||
|
||||
|
||||
|
@ -2,9 +2,8 @@
|
||||
import pytest
|
||||
|
||||
import env # noqa: F401
|
||||
|
||||
from pybind11_tests import methods_and_attributes as m
|
||||
from pybind11_tests import ConstructorStats
|
||||
from pybind11_tests import methods_and_attributes as m
|
||||
|
||||
|
||||
def test_methods_and_attributes():
|
||||
|
@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from pybind11_tests import ConstructorStats
|
||||
from pybind11_tests import modules as m
|
||||
from pybind11_tests.modules import subsubmodule as ms
|
||||
from pybind11_tests import ConstructorStats
|
||||
|
||||
|
||||
def test_nested_modules():
|
||||
@ -54,18 +54,20 @@ def test_reference_internal():
|
||||
|
||||
|
||||
def test_importing():
|
||||
from pybind11_tests.modules import OD
|
||||
from collections import OrderedDict
|
||||
|
||||
from pybind11_tests.modules import OD
|
||||
|
||||
assert OD is OrderedDict
|
||||
assert str(OD([(1, "a"), (2, "b")])) == "OrderedDict([(1, 'a'), (2, 'b')])"
|
||||
|
||||
|
||||
def test_pydoc():
|
||||
"""Pydoc needs to be able to provide help() for everything inside a pybind11 module"""
|
||||
import pybind11_tests
|
||||
import pydoc
|
||||
|
||||
import pybind11_tests
|
||||
|
||||
assert pybind11_tests.__name__ == "pybind11_tests"
|
||||
assert pybind11_tests.__doc__ == "pybind11 test module"
|
||||
assert pydoc.text.docmodule(pybind11_tests)
|
||||
|
@ -2,7 +2,6 @@
|
||||
import pytest
|
||||
|
||||
import env # noqa: F401
|
||||
|
||||
from pybind11_tests import ConstructorStats
|
||||
from pybind11_tests import multiple_inheritance as m
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
import pytest
|
||||
|
||||
import env # noqa: F401
|
||||
|
||||
from pybind11_tests import numpy_array as m
|
||||
|
||||
np = pytest.importorskip("numpy")
|
||||
|
@ -4,7 +4,6 @@ import re
|
||||
import pytest
|
||||
|
||||
import env # noqa: F401
|
||||
|
||||
from pybind11_tests import numpy_dtypes as m
|
||||
|
||||
np = pytest.importorskip("numpy")
|
||||
|
@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import pytest
|
||||
|
||||
from pybind11_tests import numpy_vectorize as m
|
||||
|
||||
np = pytest.importorskip("numpy")
|
||||
|
@ -1,7 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import pytest
|
||||
from pybind11_tests import opaque_types as m
|
||||
|
||||
from pybind11_tests import ConstructorStats, UserType
|
||||
from pybind11_tests import opaque_types as m
|
||||
|
||||
|
||||
def test_string_list():
|
||||
|
@ -1,7 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import pytest
|
||||
from pybind11_tests import operators as m
|
||||
|
||||
from pybind11_tests import ConstructorStats
|
||||
from pybind11_tests import operators as m
|
||||
|
||||
|
||||
def test_operator_overloading():
|
||||
|
@ -2,7 +2,6 @@
|
||||
import pytest
|
||||
|
||||
import env # noqa: F401
|
||||
|
||||
from pybind11_tests import pickling as m
|
||||
|
||||
try:
|
||||
|
@ -1,12 +1,13 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import division
|
||||
import pytest
|
||||
|
||||
import sys
|
||||
|
||||
import env # noqa: F401
|
||||
import pytest
|
||||
|
||||
from pybind11_tests import pytypes as m
|
||||
import env # noqa: F401
|
||||
from pybind11_tests import debug_enabled
|
||||
from pybind11_tests import pytypes as m
|
||||
|
||||
|
||||
def test_int(doc):
|
||||
|
@ -1,7 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import pytest
|
||||
from pybind11_tests import sequences_and_iterators as m
|
||||
|
||||
from pybind11_tests import ConstructorStats
|
||||
from pybind11_tests import sequences_and_iterators as m
|
||||
|
||||
|
||||
def isclose(a, b, rel_tol=1e-05, abs_tol=0.0):
|
||||
|
@ -1,9 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import pytest
|
||||
|
||||
from pybind11_tests import ConstructorStats, UserType
|
||||
from pybind11_tests import stl as m
|
||||
from pybind11_tests import UserType
|
||||
from pybind11_tests import ConstructorStats
|
||||
|
||||
|
||||
def test_vector(doc):
|
||||
|
@ -2,7 +2,6 @@
|
||||
import pytest
|
||||
|
||||
import env # noqa: F401
|
||||
|
||||
from pybind11_tests import stl_binders as m
|
||||
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import print_function, division
|
||||
from __future__ import division, print_function
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
@ -4,11 +4,9 @@
|
||||
import re
|
||||
|
||||
import ghapi.all
|
||||
|
||||
from rich import print
|
||||
from rich.syntax import Syntax
|
||||
|
||||
|
||||
ENTRY = re.compile(
|
||||
r"""
|
||||
Suggested \s changelog \s entry:
|
||||
|
Loading…
Reference in New Issue
Block a user