mirror of
https://github.com/pybind/pybind11.git
synced 2025-03-12 07:49:28 +00:00
test isinstance
This commit is contained in:
parent
b8ad03da76
commit
e5235f00f7
@ -2567,8 +2567,14 @@ str_attr_accessor object_api<D>::doc() const {
|
||||
|
||||
template <typename D>
|
||||
// Always a dict
|
||||
// https://docs.python.org/3/howto/annotations.html#accessing-the-annotations-dict-of-an-object-in-python-3-9-and-older
|
||||
object object_api<D>::annotations() const {
|
||||
return getattr(derived(), "__annotations__", dict());
|
||||
if (isinstance<type>(derived())){
|
||||
return getattr(getattr(derived(), "__dict__"), "__annotations__", dict());
|
||||
}
|
||||
else{
|
||||
return getattr(derived(), "__annotations__", dict());
|
||||
}
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
|
Loading…
Reference in New Issue
Block a user