diff --git a/python/extractor/tests/parser/class.py b/python/extractor/tests/parser/class.py index d1d4694fb3f2..ffaefbcb5dac 100644 --- a/python/extractor/tests/parser/class.py +++ b/python/extractor/tests/parser/class.py @@ -1,2 +1,2 @@ -class Foo(int, object, metaclass=type): +class Foo(int, object, metaclass=type, **kwargs): x = 5 diff --git a/python/extractor/tsg-python/python.tsg b/python/extractor/tsg-python/python.tsg index 8a9ab01e9915..4c5a9e6b0d0e 100644 --- a/python/extractor/tsg-python/python.tsg +++ b/python/extractor/tsg-python/python.tsg @@ -1277,16 +1277,18 @@ attr (@class.inner_scope -> @stmt.node) body = (named-child-index @stmt) } -; Class.bases - using `(_ !name)` as a proxy for all non-keyword arguments. +; Class.bases - using `(_ !value !name)` as a proxy for all non-keyword arguments. +; In particular, `keyword_argument` nodes have a `name` field, and `dictionary_splat` +; nodes have a `value` field. (class_definition - superclasses: (argument_list element: (_ !name) @arg) + superclasses: (argument_list element: (_ !value !name) @arg) ) @class { edge @class.class_expr -> @arg.node attr (@class.class_expr -> @arg.node) bases = (named-child-index @arg) } -; Class.keywords +; Class.keywords of the form `foo=bar` (class_definition superclasses: (argument_list element: (keyword_argument) @arg) ) @class @@ -1295,6 +1297,15 @@ attr (@class.class_expr -> @arg.node) keywords = (named-child-index @arg) } +; Class.keywords of the form `**kwargs` +(class_definition + superclasses: (argument_list element: (dictionary_splat) @arg) +) @class +{ + edge @class.class_expr -> @arg.node + attr (@class.class_expr -> @arg.node) keywords = (named-child-index @arg) +} + ;;;;;; End of Class ;;;;;; Assign statements