Skip to content

Commit d5f0446

Browse files
committed
exclude self parameter from the API-graph edge for keywordParameter
1 parent 03da627 commit d5f0446

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

python/ql/lib/semmle/python/ApiGraphs.qll

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -610,9 +610,11 @@ module API {
610610
ref.asExpr() = fn.getInnerScope().getArg(i)
611611
)
612612
or
613-
exists(string name |
613+
exists(string name, PY::Parameter param |
614614
lbl = Label::keywordParameter(name) and
615-
ref.asExpr() = fn.getInnerScope().getArgByName(name)
615+
param = fn.getInnerScope().getArgByName(name) and
616+
not param.isSelf() and
617+
ref.asExpr() = param
616618
)
617619
or
618620
lbl = Label::selfParameter() and

python/ql/test/library-tests/frameworks/data/test.expected

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,8 @@ isSource
8585
| test.py:86:49:86:59 | ControlFlowNode for getSource() | test-source |
8686
| test.py:87:56:87:66 | ControlFlowNode for getSource() | test-source |
8787
| test.py:101:29:101:31 | ControlFlowNode for arg | test-source |
88-
| test.py:104:18:104:21 | ControlFlowNode for self | test-source |
8988
| test.py:104:24:104:29 | ControlFlowNode for param1 | test-source |
9089
| test.py:104:32:104:37 | ControlFlowNode for param2 | test-source |
91-
| test.py:107:18:107:21 | ControlFlowNode for self | test-source |
9290
| test.py:107:24:107:28 | ControlFlowNode for name1 | test-source |
9391
| test.py:107:31:107:35 | ControlFlowNode for name2 | test-source |
9492
syntaxErrors

python/ql/test/library-tests/frameworks/data/test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ class OtherSubClass (ArgPos.MyClass):
101101
def otherSelfTest(self, arg, named=2, otherName=3): # test that Parameter[0] hits `arg`.
102102
pass
103103

104-
def anyParam(self, param1, param2): # Parameter[any] matches all 3.
104+
def anyParam(self, param1, param2): # Parameter[any] matches all non-self parameters
105105
pass
106106

107-
def anyNamed(self, name1, name2=2): # Parameter[any-named] matches all 3.
107+
def anyNamed(self, name1, name2=2): # Parameter[any-named] matches all non-self named parameters
108108
pass

0 commit comments

Comments
 (0)