Skip to content

Commit ea01bcf

Browse files
committed
have the Instance token be an alias for Subclass.ReturnValue
1 parent 46acce0 commit ea01bcf

4 files changed

Lines changed: 8 additions & 4 deletions

File tree

python/ql/lib/semmle/python/frameworks/data/internal/ApiGraphModelsSpecific.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ API::Node getExtraSuccessorFromNode(API::Node node, AccessPathToken token) {
5353
result = node.getMember(token.getAnArgument())
5454
or
5555
token.getName() = "Instance" and
56-
result = node.getReturn() // commonly used Token. In Python `Instance` is just an alias for `ReturnValue`
56+
result = node.getASubclass*().getReturn() // In Python `Instance` is just an alias for `Subclass.ReturnValue`
5757
or
5858
token.getName() = "Awaited" and
5959
result = node.getAwaited()

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ isSource
4141
| test.py:39:11:39:20 | ControlFlowNode for Await | test-source |
4242
| test.py:41:8:41:27 | ControlFlowNode for Attribute() | test-source |
4343
| test.py:46:7:46:16 | ControlFlowNode for SubClass() | test-source |
44+
| test.py:51:8:51:18 | ControlFlowNode for Sub2Class() | test-source |
4445
syntaxErrors
4546
| Member[foo |
4647
| Member[foo] .Member[bar] |

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,9 @@ async def async_func():
4343
class SubClass (CommonTokens.Super):
4444
pass
4545

46-
sub = SubClass()
46+
sub = SubClass()
47+
48+
class Sub2Class (CommonTokens.Class):
49+
pass
50+
51+
sub2 = Sub2Class()

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ class Sinks extends ModelInput::SinkModelCsv {
5353
}
5454
}
5555

56-
// TODO: Commonly used tokens
57-
// TODO: Should `instance()` be shorthand for `subClass*().getReturn()`?
5856
// TODO: Uniform tokens for fields
5957
// TODO: Non-positional arguments (including Named parameters)
6058
// TODO: Any argument

0 commit comments

Comments
 (0)