[clang] [clang-bindings] Add strict typing to clang Python bindings (#76664) (PR #78114)
Jannick Kremer via cfe-commits
cfe-commits at lists.llvm.org
Sun Jan 14 13:40:15 PST 2024
================
@@ -642,51 +1259,29 @@ def register(value, name):
### Cursor Kinds ###
-class BaseEnumeration(object):
- """
- Common base class for named enumerations held in sync with Index.h values.
+TEnum = TypeVar("TEnum", bound="BaseEnumeration")
- Subclasses must define their own _kinds and _name_map members, as:
- _kinds = []
- _name_map = None
- These values hold the per-subclass instances and value-to-name mappings,
- respectively.
+class BaseEnumeration(Enum):
----------------
DeinAlptraum wrote:
Since I've collected the shared functionality of all enums into this class, including e.g. `__repr__` definitions, some of them may differ slightly in output.
E.g. the representation of a `TemplateArgumentKind.INTEGRAL` is exactly `TemplateArgumentKind.INTEGRAL`, compared to `'clang.cindex.TemplateArgumentKind'>.INTEGRAL`, which is consistent with the representation of most other enums.
https://github.com/llvm/llvm-project/pull/78114
More information about the cfe-commits
mailing list