[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:43:55 PST 2024


================
@@ -3968,7 +4500,7 @@ def function_exists(self, name):
         return True
 
 
-def register_enumerations():
+def register_enumerations() -> None:
----------------
DeinAlptraum wrote:

This implementation dynamically adds the TokenKind variants, which means it also suffers from the same problems as the previoius "manual" implementation of enums: if you write e.g. `TokenKind.PUNCTUATION` in a program and typecheck it, it will throw an error since it doesn't recognize `PUNCTUATION` as a member of `TokenKind`.
I'm not sure why this one enum is outsourced to a different file and implemented via this dynamic registering approach. I'd be in favor of removing that and handling it just like the other enums.

https://github.com/llvm/llvm-project/pull/78114


More information about the cfe-commits mailing list