Michael Carlstrom cf020a1de2
feat(types) Allow setting types for attributes (#5460)
* init

* add comment

* style: pre-commit fixes

* fix extra ;

* Add annotation helper for older python versions

* style: pre-commit fixes

* test writing __annotations__ to __dict__

* style: pre-commit fixes

* revert bac to __annotations__

* use getattr for automatic init

* use std::move

* update helper

* remove stdmove

* test isinstance

* style: pre-commit fixes

* add #if 3.9

* style: pre-commit fixes

* use getattr

* add dir

* use hasattr

* try setattr

* add c++17 guard

* style: pre-commit fixes

* add compile guard

* style: pre-commit fixes

* cleanup

* comments and function name cleanup

* style: pre-commit fixes

* update test case

* style: pre-commit fixes

* add write

* added instance check

* style: pre-commit fixes

* Test for `__cpp_inline_variables` and use `static_assert()`

* Add guard: __annotations__["list_int"] was set already.

* Avoid explicit `false` in `static_assert()`.

* add redeclaration test

* style: pre-commit fixes

* add handle support to attr_with_type_hint

* store reintpreted_key

* style: pre-commit fixes

* fix str namespace

* fix scope?

* string wrap

* clang tidy

* Swap order of attr_with_type_hint implementation in cast.h (so that the `const char *` overload appears first).

* Reuse `const char *` overload from `handle` overload.

* Added comment

* style: pre-commit fixes

* line up comment

* fixed spelling error

* Add missing period

* Introduce `detail::always_false<>` to make the new `static_assert()` more readable.

* Copy `attr` comment for `const char *` overload, for consistency.

* static_assert(std::false_type::value, ...)

* Revert "static_assert(std::false_type::value, ...)"

This reverts commit 999b668688b5b965a6f929a5a7f8af5176c8a21d.

* Add comment for `always_false`

* add test for inspect.get_annotations()

* style: pre-commit fixes

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Ralf W. Grosse-Kunstleve <rgrossekunst@nvidia.com>
2024-12-21 16:22:08 -08:00
..
2024-10-07 14:12:04 -07:00
2024-05-24 12:26:40 -04:00
2022-02-14 11:36:22 -08:00
2024-10-07 14:12:04 -07:00
2022-02-14 11:36:22 -08:00
2024-07-18 14:50:38 -04:00