-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 999b668. * 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 <[email protected]>
- Loading branch information
1 parent
5b503f7
commit cf020a1
Showing
6 changed files
with
204 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters