Merge branch 'master' into smart_holder

This commit is contained in:
Ralf W. Grosse-Kunstleve 2021-07-13 05:57:50 -07:00
commit 88cc350075
11 changed files with 195 additions and 57 deletions

View File

@ -15,7 +15,7 @@
repos:
# Standard hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
rev: v4.0.1
hooks:
- id: check-added-large-files
- id: check-case-conflict
@ -31,9 +31,14 @@ repos:
- id: fix-encoding-pragma
exclude: ^noxfile.py$
- repo: https://github.com/asottile/pyupgrade
rev: v2.21.0
hooks:
- id: pyupgrade
# Black, the code formatter, natively supports pre-commit
- repo: https://github.com/psf/black
rev: 20.8b1
rev: 21.6b0
hooks:
- id: black
# By default, this ignores pyi files, though black supports them
@ -42,14 +47,14 @@ repos:
# Changes tabs to spaces
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.1.9
rev: v1.1.10
hooks:
- id: remove-tabs
exclude: (^docs/.*|\.patch)?$
# Flake8 also supports pre-commit natively (same author)
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
rev: 3.9.2
hooks:
- id: flake8
additional_dependencies: [flake8-bugbear, pep8-naming]
@ -66,7 +71,7 @@ repos:
# Check static types with mypy
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.800
rev: v0.910
hooks:
- id: mypy
# The default Python type ignores .pyi files, so let's rerun if detected
@ -74,6 +79,7 @@ repos:
files: ^pybind11.*\.pyi?$
# Running per-file misbehaves a bit, so just run on all files, it's fast
pass_filenames: false
additional_dependencies: [typed_ast]
# Checks the manifest for missing files (native support)
- repo: https://github.com/mgedmin/check-manifest

View File

@ -9,12 +9,143 @@ Starting with version 1.8.0, pybind11 releases use a `semantic versioning
v2.7.0 (TBA, not yet released)
------------------------------
New features:
* Enable ``py::implicitly_convertible<py::none, ...>`` for
``py::class_``-wrapped types.
`#3059 <https://github.com/pybind/pybind11/pull/3059>`_
* Allow function pointer extraction from overloaded functions.
`#2944 <https://github.com/pybind/pybind11/pull/2944>`_
* NumPy: added ``.char_()`` to type which gives the NumPy public ``char``
result, which also distinguishes types by bit length (unlike ``.kind()``).
`#2864 <https://github.com/pybind/pybind11/pull/2864>`_
* Add ``pybind11::bytearray`` to manipulate ``bytearray`` similar to ``bytes``.
`#2799 <https://github.com/pybind/pybind11/pull/2799>`_
* ``pybind11/stl/filesystem.h`` registers a type caster that, on C++17/Python
3.6+, converts ``std::filesystem::path`` to ``pathlib.Path`` and any
``os.PathLike`` to ``std::filesystem::path``.
`#2730 <https://github.com/pybind/pybind11/pull/2730>`_
Changes:
* ``py::str`` changed to exclusively hold `PyUnicodeObject`. Previously
``py::str`` could also hold `bytes`, which is probably surprising, was
never documented, and can mask bugs (e.g. accidental use of ``py::str``
instead of ``py::bytes``).
`#2409 <https://github.com/pybind/pybind11/pull/2409>`_
* Add a safety guard to ensure that the Python GIL is held when C++ calls back
into Python via ``object_api<>::operator()`` (e.g. ``py::function``
``__call__``). (This feature is available for Python 3.6+ only.)
`#2919 <https://github.com/pybind/pybind11/pull/2919>`_
* Catch a missing ``self`` argument in calls to ``__init__()``.
`#2914 <https://github.com/pybind/pybind11/pull/2914>`_
* Use ``std::string_view`` if available to avoid a copy when passing an object
to a ``std::ostream``.
`#3042 <https://github.com/pybind/pybind11/pull/3042>`_
* An important warning about thread safety was added to the ``iostream.h``
documentation; attempts to make ``py::scoped_ostream_redirect`` thread safe
have been removed, as it was only partially effective.
`#2995 <https://github.com/pybind/pybind11/pull/2995>`_
Fixes:
* Performance: avoid unnecessary strlen calls.
`#3058 <https://github.com/pybind/pybind11/pull/3058>`_
* Fix auto-generated documentation string when using ``const T`` in
``pyarray_t``.
`#3020 <https://github.com/pybind/pybind11/pull/3020>`_
* Unify error messages thrown by ``simple_collector``/``unpacking_collector``.
`#3013 <https://github.com/pybind/pybind11/pull/3013>`_
* ``pybind11::builtin_exception`` is now explicitly exported, which means the
types included/defined in different modules are identical, and exceptions
raised in different modules can be caught correctly. The documentation was
updated to explain that custom exceptions that are used across module
boundaries need to be explicitly exported as well.
`#2999 <https://github.com/pybind/pybind11/pull/2999>`_
* Fixed exception when printing UTF-8 to a ``scoped_ostream_redirect``.
`#2982 <https://github.com/pybind/pybind11/pull/2982>`_
* Pickle support enhancement: ``setstate`` implementation will attempt to
``setattr`` ``__dict__`` only if the unpickled ``dict`` object is not empty,
to not force use of ``py::dynamic_attr()`` unnecessarily.
`#2972 <https://github.com/pybind/pybind11/pull/2972>`_
* Allow negative timedelta values to roundtrip.
`#2870 <https://github.com/pybind/pybind11/pull/2870>`_
* Fix unchecked errors could potentially swallow signals/other exceptions.
`#2863 <https://github.com/pybind/pybind11/pull/2863>`_
* Add null pointer check with ``std::localtime``.
`#2846 <https://github.com/pybind/pybind11/pull/2846>`_
* Fix the ``weakref`` constructor from ``py::object`` to create a new
``weakref`` on conversion.
`#2832 <https://github.com/pybind/pybind11/pull/2832>`_
* Avoid relying on exceptions in C++17 when getting a ``shared_ptr`` holder
from a ``shared_from_this`` class.
`#2819 <https://github.com/pybind/pybind11/pull/2819>`_
Build system improvements:
* In ``setup_helpers.py``, test for platforms that have some multiprocessing
features but lack semaphores, which ``ParallelCompile`` requires.
`#3043 <https://github.com/pybind/pybind11/pull/3043>`_
* Fix ``pybind11_INCLUDE_DIR`` in case ``CMAKE_INSTALL_INCLUDEDIR`` is
absolute.
`#3005 <https://github.com/pybind/pybind11/pull/3005>`_
* Fix bug not respecting ``WITH_SOABI`` or ``WITHOUT_SOABI`` to CMake.
`#2938 <https://github.com/pybind/pybind11/pull/2938>`_
* Fix the default ``Pybind11Extension`` compilation flags with a Mingw64 python.
`#2921 <https://github.com/pybind/pybind11/pull/2921>`_
* Clang on Windows: do not pass ``/MP`` (ignored flag).
`#2824 <https://github.com/pybind/pybind11/pull/2824>`_
Backend and tidying up:
* Enable clang-tidy performance, readability, and modernization checks
throughout the codebase to enforce best coding practices.
`#3046 <https://github.com/pybind/pybind11/pull/3046>`_,
`#3049 <https://github.com/pybind/pybind11/pull/3049>`_,
`#3051 <https://github.com/pybind/pybind11/pull/3051>`_,
`#3052 <https://github.com/pybind/pybind11/pull/3052>`_, and
`#3080 <https://github.com/pybind/pybind11/pull/3080>`_
* Checks for common misspellings were added to the pre-commit hooks.
`#3076 <https://github.com/pybind/pybind11/pull/3076>`_
* Changed ``Werror`` to stricter ``Werror-all`` for Intel compiler and fixed
minor issues.
`#2948 <https://github.com/pybind/pybind11/pull/2948>`_
* Fixed compilation with GCC < 5 when the user defines ``_GLIBCXX_USE_CXX11_ABI``.
`#2956 <https://github.com/pybind/pybind11/pull/2956>`_
* Added nox support for easier local testing and linting of contributions.
`#3101 <https://github.com/pybind/pybind11/pull/3101>`_
v2.6.2 (Jan 26, 2021)
---------------------

View File

@ -1,3 +1,35 @@
[build-system]
requires = ["setuptools>=42", "wheel", "cmake>=3.18", "ninja"]
build-backend = "setuptools.build_meta"
[tool.check-manifest]
ignore = [
"tests/**",
"docs/**",
"tools/**",
"include/**",
".*",
"pybind11/include/**",
"pybind11/share/**",
"CMakeLists.txt",
"noxfile.py",
]
[tool.mypy]
files = "pybind11"
python_version = "2.7"
warn_unused_configs = true
disallow_any_generics = true
disallow_subclassing_any = true
disallow_untyped_calls = true
disallow_untyped_defs = true
disallow_incomplete_defs = true
check_untyped_defs = true
disallow_untyped_decorators = true
no_implicit_optional = true
warn_redundant_casts = true
warn_unused_ignores = true
warn_return_any = true
no_implicit_reexport = true
strict_equality = true

View File

@ -37,18 +37,6 @@ zip_safe = False
[bdist_wheel]
universal=1
[check-manifest]
ignore =
tests/**
docs/**
tools/**
include/**
.*
pybind11/include/**
pybind11/share/**
CMakeLists.txt
noxfile.py
[flake8]
max-line-length = 99
@ -62,25 +50,6 @@ ignore =
# Black conflict
W503, E203
[mypy]
files = pybind11
python_version = 2.7
warn_unused_configs = True
# Currently (0.800) identical to --strict
disallow_any_generics = True
disallow_subclassing_any = True
disallow_untyped_calls = True
disallow_untyped_defs = True
disallow_incomplete_defs = True
check_untyped_defs = True
disallow_untyped_decorators = True
no_implicit_optional = True
warn_redundant_casts = True
warn_unused_ignores = True
warn_return_any = True
no_implicit_reexport = True
strict_equality = True
[tool:pytest]
timeout = 300

View File

@ -134,7 +134,7 @@ def test_build_sdist(monkeypatch, tmpdir):
with tarfile.open(str(sdist)) as tar:
start = tar.getnames()[0] + "/"
version = start[9:-1]
simpler = set(n.split("/", 1)[-1] for n in tar.getnames()[1:])
simpler = {n.split("/", 1)[-1] for n in tar.getnames()[1:]}
with contextlib.closing(
tar.extractfile(tar.getmember(start + "setup.py"))
@ -146,9 +146,9 @@ def test_build_sdist(monkeypatch, tmpdir):
) as f:
pyproject_toml = f.read()
files = set("pybind11/{}".format(n) for n in all_files)
files = {"pybind11/{}".format(n) for n in all_files}
files |= sdist_files
files |= set("pybind11{}".format(n) for n in local_sdist_files)
files |= {"pybind11{}".format(n) for n in local_sdist_files}
files.add("pybind11.egg-info/entry_points.txt")
files.add("pybind11.egg-info/requires.txt")
assert simpler == files
@ -189,7 +189,7 @@ def test_build_global_dist(monkeypatch, tmpdir):
with tarfile.open(str(sdist)) as tar:
start = tar.getnames()[0] + "/"
version = start[16:-1]
simpler = set(n.split("/", 1)[-1] for n in tar.getnames()[1:])
simpler = {n.split("/", 1)[-1] for n in tar.getnames()[1:]}
with contextlib.closing(
tar.extractfile(tar.getmember(start + "setup.py"))
@ -201,9 +201,9 @@ def test_build_global_dist(monkeypatch, tmpdir):
) as f:
pyproject_toml = f.read()
files = set("pybind11/{}".format(n) for n in all_files)
files = {"pybind11/{}".format(n) for n in all_files}
files |= sdist_files
files |= set("pybind11_global{}".format(n) for n in local_sdist_files)
files |= {"pybind11_global{}".format(n) for n in local_sdist_files}
assert simpler == files
with open(os.path.join(MAIN_DIR, "tools", "setup_global.py.in"), "rb") as f:
@ -228,7 +228,7 @@ def tests_build_wheel(monkeypatch, tmpdir):
(wheel,) = tmpdir.visit("*.whl")
files = set("pybind11/{}".format(n) for n in all_files)
files = {"pybind11/{}".format(n) for n in all_files}
files |= {
"dist-info/LICENSE",
"dist-info/METADATA",
@ -241,10 +241,10 @@ def tests_build_wheel(monkeypatch, tmpdir):
with zipfile.ZipFile(str(wheel)) as z:
names = z.namelist()
trimmed = set(n for n in names if "dist-info" not in n)
trimmed |= set(
trimmed = {n for n in names if "dist-info" not in n}
trimmed |= {
"dist-info/{}".format(n.split("/", 1)[-1]) for n in names if "dist-info" in n
)
}
assert files == trimmed
@ -258,8 +258,8 @@ def tests_build_global_wheel(monkeypatch, tmpdir):
(wheel,) = tmpdir.visit("*.whl")
files = set("data/data/{}".format(n) for n in src_files)
files |= set("data/headers/{}".format(n[8:]) for n in headers)
files = {"data/data/{}".format(n) for n in src_files}
files |= {"data/headers/{}".format(n[8:]) for n in headers}
files |= {
"dist-info/LICENSE",
"dist-info/METADATA",
@ -272,6 +272,6 @@ def tests_build_global_wheel(monkeypatch, tmpdir):
names = z.namelist()
beginning = names[0].split("/", 1)[0].rsplit(".", 1)[0]
trimmed = set(n[len(beginning) + 1 :] for n in names)
trimmed = {n[len(beginning) + 1 :] for n in names}
assert files == trimmed

View File

@ -50,7 +50,7 @@ def test_single_char_arguments():
"""Tests failures for passing invalid inputs to char-accepting functions"""
def toobig_message(r):
return "Character code point not in range({0:#x})".format(r)
return "Character code point not in range({:#x})".format(r)
toolong_message = "Expected a character, but multi-character string found"

View File

@ -144,7 +144,7 @@ def test_async_callbacks():
from time import sleep
sleep(0.5)
assert sum(res) == sum([x + 3 for x in work])
assert sum(res) == sum(x + 3 for x in work)
def test_async_async_callbacks():

View File

@ -321,7 +321,7 @@ def test_bind_protected_functions():
def test_brace_initialization():
""" Tests that simple POD classes can be constructed using C++11 brace initialization """
"""Tests that simple POD classes can be constructed using C++11 brace initialization"""
a = m.BraceInitialization(123, "test")
assert a.field1 == 123
assert a.field2 == "test"

View File

@ -65,7 +65,7 @@ def test_set(capture, doc):
"""
)
assert not m.set_contains(set([]), 42)
assert not m.set_contains(set(), 42)
assert m.set_contains({42}, 42)
assert m.set_contains({"foo"}, "foo")
@ -448,7 +448,7 @@ def test_memoryview(method, args, fmt, expected_view):
view_as_list = list(view)
else:
# Using max to pick non-zero byte (big-endian vs little-endian).
view_as_list = [max([ord(c) for c in s]) for s in view]
view_as_list = [max(ord(c) for c in s) for s in view]
assert view_as_list == list(expected_view)

View File

@ -104,7 +104,7 @@ def test_sequence():
def test_sequence_length():
"""#2076: Exception raised by len(arg) should be propagated """
"""#2076: Exception raised by len(arg) should be propagated"""
class BadLen(RuntimeError):
pass
@ -187,7 +187,7 @@ def test_iterator_passthrough():
def test_iterator_rvp():
"""#388: Can't make iterators via make_iterator() with different r/v policies """
"""#388: Can't make iterators via make_iterator() with different r/v policies"""
import pybind11_tests.sequences_and_iterators as m
assert list(m.make_iterator_1()) == [1, 2, 3]

View File

@ -278,7 +278,7 @@ def test_array_cast_sequence():
def test_issue_1561():
""" check fix for issue #1561 """
"""check fix for issue #1561"""
bar = m.Issue1561Outer()
bar.list = [m.Issue1561Inner("bar")]
bar.list