| 2641 | |
| 2642 | template <typename D> |
| 2643 | object object_api<D>::annotations() const { |
| 2644 | // This is needed again because of the lazy annotations added in 3.14+ |
| 2645 | #if PY_VERSION_HEX < 0x030A0000 || PY_VERSION_HEX >= 0x030E0000 |
| 2646 | // https://docs.python.org/3/howto/annotations.html#accessing-the-annotations-dict-of-an-object-in-python-3-9-and-older |
| 2647 | if (!hasattr(derived(), "__annotations__")) { |
| 2648 | setattr(derived(), "__annotations__", dict()); |
| 2649 | } |
| 2650 | return attr("__annotations__"); |
| 2651 | #else |
| 2652 | return getattr(derived(), "__annotations__", dict()); |
| 2653 | #endif |
| 2654 | } |
| 2655 | |
| 2656 | template <typename D> |
| 2657 | handle object_api<D>::get_type() const { |