mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-28 16:11:59 +00:00
Applied pre-commit formatting.
This commit is contained in:
parent
7e7f9ce67b
commit
e8aa81bd9a
@ -102,27 +102,25 @@ inline std::string replace_newlines_and_squash(const char *text) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// Type trait checker for `descr`.
|
/// Type trait checker for `descr`.
|
||||||
template<typename>
|
template <typename>
|
||||||
struct is_descr : std::false_type {};
|
struct is_descr : std::false_type {};
|
||||||
|
|
||||||
template<size_t N, typename... Ts>
|
template <size_t N, typename... Ts>
|
||||||
struct is_descr<descr<N, Ts...>> : std::true_type {};
|
struct is_descr<descr<N, Ts...>> : std::true_type {};
|
||||||
|
|
||||||
template<size_t N, typename... Ts>
|
template <size_t N, typename... Ts>
|
||||||
struct is_descr<const descr<N, Ts...>> : std::true_type {};
|
struct is_descr<const descr<N, Ts...>> : std::true_type {};
|
||||||
|
|
||||||
/// Checks for `return_name` in `type_caster` to replace `name` for return type hints.
|
/// Checks for `return_name` in `type_caster` to replace `name` for return type hints.
|
||||||
/// this is useful for having a different python type hint for args vs return value,
|
/// this is useful for having a different python type hint for args vs return value,
|
||||||
/// e.g., `std::filesystem::path` -> Arg: `Union[os.PathLike, str, bytes]`, return: `Path`.
|
/// e.g., `std::filesystem::path` -> Arg: `Union[os.PathLike, str, bytes]`, return: `Path`.
|
||||||
template<typename T, typename Enable = void>
|
template <typename T, typename Enable = void>
|
||||||
struct as_return_type
|
struct as_return_type {
|
||||||
{
|
|
||||||
static constexpr auto name = T::name;
|
static constexpr auto name = T::name;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct as_return_type<T, typename std::enable_if_t<is_descr<decltype(T::return_name)>::value>>
|
struct as_return_type<T, typename std::enable_if_t<is_descr<decltype(T::return_name)>::value>> {
|
||||||
{
|
|
||||||
static constexpr auto name = T::return_name;
|
static constexpr auto name = T::return_name;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -344,9 +342,8 @@ protected:
|
|||||||
|
|
||||||
/* Generate a readable signature describing the function's arguments and return
|
/* Generate a readable signature describing the function's arguments and return
|
||||||
value types */
|
value types */
|
||||||
static constexpr auto signature
|
static constexpr auto signature = const_name("(") + cast_in::arg_names
|
||||||
= const_name("(") + cast_in::arg_names + const_name(") -> ")
|
+ const_name(") -> ") + as_return_type<cast_out>::name;
|
||||||
+ as_return_type<cast_out>::name;
|
|
||||||
PYBIND11_DESCR_CONSTEXPR auto types = decltype(signature)::types();
|
PYBIND11_DESCR_CONSTEXPR auto types = decltype(signature)::types();
|
||||||
|
|
||||||
/* Register the function with Python from generic (non-templated) code */
|
/* Register the function with Python from generic (non-templated) code */
|
||||||
|
@ -261,7 +261,10 @@ def test_fs_path(doc):
|
|||||||
assert m.parent_path(b"foo/bar") == Path("foo")
|
assert m.parent_path(b"foo/bar") == Path("foo")
|
||||||
assert m.parent_path(PseudoStrPath()) == Path("foo")
|
assert m.parent_path(PseudoStrPath()) == Path("foo")
|
||||||
assert m.parent_path(PseudoBytesPath()) == Path("foo")
|
assert m.parent_path(PseudoBytesPath()) == Path("foo")
|
||||||
assert doc(m.parent_path) == "parent_path(arg0: Union[os.PathLike, str, bytes]) -> Path"
|
assert (
|
||||||
|
doc(m.parent_path)
|
||||||
|
== "parent_path(arg0: Union[os.PathLike, str, bytes]) -> Path"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skipif(not hasattr(m, "load_variant"), reason="no <variant>")
|
@pytest.mark.skipif(not hasattr(m, "load_variant"), reason="no <variant>")
|
||||||
|
Loading…
Reference in New Issue
Block a user