Skip to content

Fix superclass keyword arguments in Python. #480

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,10 @@ inherit .parent_module

(class_definition
superclasses: (argument_list
(_) @superclass)) @class
[
(identifier)
(attribute)
] @superclass)) @class
{
edge @class.super_scope -> @superclass.output
}
Expand Down
11 changes: 7 additions & 4 deletions languages/tree-sitter-stack-graphs-python/test/superclasses.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
class A:
def __init_subclass__(cls, foo):
pass

def __init__(self):
self.some_attr = 2

def some_method(self):
print self

class B(A):
class B(A, foo="Bar"):
def method2(self):
print self.some_attr, self.some_method()
# ^ defined: 3
# ^ defined: 5, 14
# ^ defined: 6
# ^ defined: 8, 17

def some_method(self):
pass

def other(self):
super().some_method()
# ^ defined: 5
# ^ defined: 8
Loading