Skip to content
Open
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ jobs:
-DDOWNLOAD_CATCH=ON
-DDOWNLOAD_EIGEN=ON
-DCMAKE_CXX_STANDARD=14
-DCMAKE_CXX_FLAGS="-DPYBIND11_DISABLE_SUPPORTS_TYPE_HINTS"
-DPYBIND11_INTERNALS_VERSION=10000000

# Checks to makes sure defining `_` is allowed
Expand Down
6 changes: 4 additions & 2 deletions include/pybind11/cast.h
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,10 @@ struct type_caster<T, enable_if_t<std::is_arithmetic<T>::value && !is_std_char_t
}

PYBIND11_TYPE_CASTER(T,
io_name<std::is_integral<T>::value>(
"typing.SupportsInt", "int", "typing.SupportsFloat", "float"));
io_name<std::is_integral<T>::value>(PYBIND11_INT_ARGUMENT_TYPE_HINT,
"int",
PYBIND11_FLOAT_ARGUMENT_TYPE_HINT,
"float"));
};

template <typename T>
Expand Down
8 changes: 8 additions & 0 deletions include/pybind11/detail/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,14 @@
# define PYBIND11_TYPE_GUARD_TYPE_HINT "typing_extensions.TypeGuard"
#endif

#ifndef PYBIND11_DISABLE_SUPPORTS_TYPE_HINTS
# define PYBIND11_FLOAT_ARGUMENT_TYPE_HINT "typing.SupportsFloat"
# define PYBIND11_INT_ARGUMENT_TYPE_HINT "typing.SupportsInt"
#else
# define PYBIND11_FLOAT_ARGUMENT_TYPE_HINT "float"
# define PYBIND11_INT_ARGUMENT_TYPE_HINT "int"
#endif

// #define PYBIND11_STR_LEGACY_PERMISSIVE
// If DEFINED, pybind11::str can hold PyUnicodeObject or PyBytesObject
// (probably surprising and never documented, but this was the
Expand Down
Loading