mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-27 07:32:02 +00:00
Merge branch 'pybind:master' into master
This commit is contained in:
commit
8f50fcd8bb
@ -24,7 +24,7 @@ exclude: ^tools/JoinPaths.cmake$
|
|||||||
repos:
|
repos:
|
||||||
# Standard hooks
|
# Standard hooks
|
||||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
rev: "v4.3.0"
|
rev: "v4.4.0"
|
||||||
hooks:
|
hooks:
|
||||||
- id: check-added-large-files
|
- id: check-added-large-files
|
||||||
- id: check-case-conflict
|
- id: check-case-conflict
|
||||||
@ -41,7 +41,7 @@ repos:
|
|||||||
|
|
||||||
# Upgrade old Python syntax
|
# Upgrade old Python syntax
|
||||||
- repo: https://github.com/asottile/pyupgrade
|
- repo: https://github.com/asottile/pyupgrade
|
||||||
rev: "v3.2.0"
|
rev: "v3.3.0"
|
||||||
hooks:
|
hooks:
|
||||||
- id: pyupgrade
|
- id: pyupgrade
|
||||||
args: [--py36-plus]
|
args: [--py36-plus]
|
||||||
@ -80,7 +80,7 @@ repos:
|
|||||||
|
|
||||||
# Autoremoves unused imports
|
# Autoremoves unused imports
|
||||||
- repo: https://github.com/hadialqattan/pycln
|
- repo: https://github.com/hadialqattan/pycln
|
||||||
rev: "v2.1.1"
|
rev: "v2.1.2"
|
||||||
hooks:
|
hooks:
|
||||||
- id: pycln
|
- id: pycln
|
||||||
stages: [manual]
|
stages: [manual]
|
||||||
@ -108,7 +108,7 @@ repos:
|
|||||||
|
|
||||||
# Flake8 also supports pre-commit natively (same author)
|
# Flake8 also supports pre-commit natively (same author)
|
||||||
- repo: https://github.com/PyCQA/flake8
|
- repo: https://github.com/PyCQA/flake8
|
||||||
rev: "5.0.4"
|
rev: "6.0.0"
|
||||||
hooks:
|
hooks:
|
||||||
- id: flake8
|
- id: flake8
|
||||||
exclude: ^(docs/.*|tools/.*)$
|
exclude: ^(docs/.*|tools/.*)$
|
||||||
@ -116,7 +116,7 @@ repos:
|
|||||||
|
|
||||||
# PyLint has native support - not always usable, but works for us
|
# PyLint has native support - not always usable, but works for us
|
||||||
- repo: https://github.com/PyCQA/pylint
|
- repo: https://github.com/PyCQA/pylint
|
||||||
rev: "v2.15.5"
|
rev: "v2.15.8"
|
||||||
hooks:
|
hooks:
|
||||||
- id: pylint
|
- id: pylint
|
||||||
files: ^pybind11
|
files: ^pybind11
|
||||||
@ -132,7 +132,7 @@ repos:
|
|||||||
|
|
||||||
# Check static types with mypy
|
# Check static types with mypy
|
||||||
- repo: https://github.com/pre-commit/mirrors-mypy
|
- repo: https://github.com/pre-commit/mirrors-mypy
|
||||||
rev: "v0.982"
|
rev: "v0.991"
|
||||||
hooks:
|
hooks:
|
||||||
- id: mypy
|
- id: mypy
|
||||||
args: []
|
args: []
|
||||||
@ -141,7 +141,7 @@ repos:
|
|||||||
|
|
||||||
# Checks the manifest for missing files (native support)
|
# Checks the manifest for missing files (native support)
|
||||||
- repo: https://github.com/mgedmin/check-manifest
|
- repo: https://github.com/mgedmin/check-manifest
|
||||||
rev: "0.48"
|
rev: "0.49"
|
||||||
hooks:
|
hooks:
|
||||||
- id: check-manifest
|
- id: check-manifest
|
||||||
# This is a slow hook, so only run this if --hook-stage manual is passed
|
# This is a slow hook, so only run this if --hook-stage manual is passed
|
||||||
@ -175,7 +175,7 @@ repos:
|
|||||||
|
|
||||||
# Clang format the codebase automatically
|
# Clang format the codebase automatically
|
||||||
- repo: https://github.com/pre-commit/mirrors-clang-format
|
- repo: https://github.com/pre-commit/mirrors-clang-format
|
||||||
rev: "v14.0.6"
|
rev: "v15.0.4"
|
||||||
hooks:
|
hooks:
|
||||||
- id: clang-format
|
- id: clang-format
|
||||||
types_or: [c++, c, cuda]
|
types_or: [c++, c, cuda]
|
||||||
|
@ -91,7 +91,8 @@ public:
|
|||||||
template <typename T_, \
|
template <typename T_, \
|
||||||
::pybind11::detail::enable_if_t< \
|
::pybind11::detail::enable_if_t< \
|
||||||
std::is_same<type, ::pybind11::detail::remove_cv_t<T_>>::value, \
|
std::is_same<type, ::pybind11::detail::remove_cv_t<T_>>::value, \
|
||||||
int> = 0> \
|
int> \
|
||||||
|
= 0> \
|
||||||
static ::pybind11::handle cast( \
|
static ::pybind11::handle cast( \
|
||||||
T_ *src, ::pybind11::return_value_policy policy, ::pybind11::handle parent) { \
|
T_ *src, ::pybind11::return_value_policy policy, ::pybind11::handle parent) { \
|
||||||
if (!src) \
|
if (!src) \
|
||||||
|
@ -209,10 +209,11 @@ struct constructor {
|
|||||||
extra...);
|
extra...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Class,
|
template <
|
||||||
|
typename Class,
|
||||||
typename... Extra,
|
typename... Extra,
|
||||||
enable_if_t<Class::has_alias && std::is_constructible<Cpp<Class>, Args...>::value,
|
enable_if_t<Class::has_alias && std::is_constructible<Cpp<Class>, Args...>::value, int>
|
||||||
int> = 0>
|
= 0>
|
||||||
static void execute(Class &cl, const Extra &...extra) {
|
static void execute(Class &cl, const Extra &...extra) {
|
||||||
cl.def(
|
cl.def(
|
||||||
"__init__",
|
"__init__",
|
||||||
@ -229,10 +230,11 @@ struct constructor {
|
|||||||
extra...);
|
extra...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Class,
|
template <
|
||||||
|
typename Class,
|
||||||
typename... Extra,
|
typename... Extra,
|
||||||
enable_if_t<Class::has_alias && !std::is_constructible<Cpp<Class>, Args...>::value,
|
enable_if_t<Class::has_alias && !std::is_constructible<Cpp<Class>, Args...>::value, int>
|
||||||
int> = 0>
|
= 0>
|
||||||
static void execute(Class &cl, const Extra &...extra) {
|
static void execute(Class &cl, const Extra &...extra) {
|
||||||
cl.def(
|
cl.def(
|
||||||
"__init__",
|
"__init__",
|
||||||
@ -248,10 +250,11 @@ struct constructor {
|
|||||||
// Implementing class for py::init_alias<...>()
|
// Implementing class for py::init_alias<...>()
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
struct alias_constructor {
|
struct alias_constructor {
|
||||||
template <typename Class,
|
template <
|
||||||
|
typename Class,
|
||||||
typename... Extra,
|
typename... Extra,
|
||||||
enable_if_t<Class::has_alias && std::is_constructible<Alias<Class>, Args...>::value,
|
enable_if_t<Class::has_alias && std::is_constructible<Alias<Class>, Args...>::value, int>
|
||||||
int> = 0>
|
= 0>
|
||||||
static void execute(Class &cl, const Extra &...extra) {
|
static void execute(Class &cl, const Extra &...extra) {
|
||||||
cl.def(
|
cl.def(
|
||||||
"__init__",
|
"__init__",
|
||||||
|
@ -279,7 +279,7 @@ struct type_caster<Type, typename eigen_tensor_helper<Type>::ValidType> {
|
|||||||
case return_value_policy::take_ownership:
|
case return_value_policy::take_ownership:
|
||||||
if (std::is_const<C>::value) {
|
if (std::is_const<C>::value) {
|
||||||
// This cast is ugly, and might be UB in some cases, but we don't have an
|
// This cast is ugly, and might be UB in some cases, but we don't have an
|
||||||
// alterantive here as we must free that memory
|
// alternative here as we must free that memory
|
||||||
Helper::free(const_cast<Type *>(src));
|
Helper::free(const_cast<Type *>(src));
|
||||||
pybind11_fail("Cannot take ownership of a const reference");
|
pybind11_fail("Cannot take ownership of a const reference");
|
||||||
}
|
}
|
||||||
|
@ -1426,9 +1426,9 @@ template <typename T, enable_if_t<has_operator_delete<T>::value, int> = 0>
|
|||||||
void call_operator_delete(T *p, size_t, size_t) {
|
void call_operator_delete(T *p, size_t, size_t) {
|
||||||
T::operator delete(p);
|
T::operator delete(p);
|
||||||
}
|
}
|
||||||
template <
|
template <typename T,
|
||||||
typename T,
|
enable_if_t<!has_operator_delete<T>::value && has_operator_delete_size<T>::value, int>
|
||||||
enable_if_t<!has_operator_delete<T>::value && has_operator_delete_size<T>::value, int> = 0>
|
= 0>
|
||||||
void call_operator_delete(T *p, size_t s, size_t) {
|
void call_operator_delete(T *p, size_t s, size_t) {
|
||||||
T::operator delete(p, s);
|
T::operator delete(p, s);
|
||||||
}
|
}
|
||||||
|
@ -232,7 +232,8 @@ public:
|
|||||||
detail::enable_if_t<detail::all_of<detail::none_of<std::is_base_of<handle, T>,
|
detail::enable_if_t<detail::all_of<detail::none_of<std::is_base_of<handle, T>,
|
||||||
detail::is_pyobj_ptr_or_nullptr_t<T>>,
|
detail::is_pyobj_ptr_or_nullptr_t<T>>,
|
||||||
std::is_convertible<T, PyObject *>>::value,
|
std::is_convertible<T, PyObject *>>::value,
|
||||||
int> = 0>
|
int>
|
||||||
|
= 0>
|
||||||
// NOLINTNEXTLINE(google-explicit-constructor)
|
// NOLINTNEXTLINE(google-explicit-constructor)
|
||||||
handle(T &obj) : m_ptr(obj) {}
|
handle(T &obj) : m_ptr(obj) {}
|
||||||
|
|
||||||
|
@ -173,7 +173,8 @@ struct AdderBase {
|
|||||||
using DataVisitor = std::function<void(const Data &)>;
|
using DataVisitor = std::function<void(const Data &)>;
|
||||||
|
|
||||||
virtual void
|
virtual void
|
||||||
operator()(const Data &first, const Data &second, const DataVisitor &visitor) const = 0;
|
operator()(const Data &first, const Data &second, const DataVisitor &visitor) const
|
||||||
|
= 0;
|
||||||
virtual ~AdderBase() = default;
|
virtual ~AdderBase() = default;
|
||||||
AdderBase() = default;
|
AdderBase() = default;
|
||||||
AdderBase(const AdderBase &) = delete;
|
AdderBase(const AdderBase &) = delete;
|
||||||
|
Loading…
Reference in New Issue
Block a user