mirror of
https://github.com/github/codeql.git
synced 2026-05-04 13:15:21 +02:00
Python: Enhance points-to to support type-hint analysis.
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
| test.py:1:6:1:11 | test.py:1 | ControlFlowNode for ImportExpr | import | ../../lib/typing.py:0:0:0:0 | Module typing |
|
||||
| test.py:1:6:1:11 | test.py:1 | ControlFlowNode for ImportExpr | import | ../../lib/typing.py:0:0:0:0 | Module typing |
|
||||
| test.py:1:20:1:27 | test.py:1 | ControlFlowNode for ImportMember | import | ../../lib/typing.py:18:12:18:32 | _Optional() |
|
||||
| test.py:1:30:1:32 | test.py:1 | ControlFlowNode for ImportMember | import | ../../lib/typing.py:23:1:23:23 | class Set |
|
||||
| test.py:3:1:3:32 | test.py:3 | ControlFlowNode for FunctionExpr | import | test.py:3:1:3:32 | Function foo |
|
||||
| test.py:3:11:3:18 | test.py:3 | ControlFlowNode for Optional | import | ../../lib/typing.py:18:12:18:32 | _Optional() |
|
||||
| test.py:3:11:3:23 | test.py:3 | ControlFlowNode for Subscript | import | file://:0:0:0:0 | _Optional()[builtin-class int] |
|
||||
| test.py:3:20:3:22 | test.py:3 | ControlFlowNode for int | import | file://:0:0:0:0 | builtin-class int |
|
||||
| test.py:3:29:3:31 | test.py:3 | ControlFlowNode for int | import | file://:0:0:0:0 | builtin-class int |
|
||||
| test.py:6:1:6:20 | test.py:6 | ControlFlowNode for FunctionExpr | import | test.py:6:1:6:20 | Function bar |
|
||||
| test.py:6:11:6:13 | test.py:6 | ControlFlowNode for set | import | file://:0:0:0:0 | builtin-class set |
|
||||
| test.py:6:17:6:19 | test.py:6 | ControlFlowNode for Set | import | ../../lib/typing.py:23:1:23:23 | class Set |
|
||||
@@ -0,0 +1,8 @@
|
||||
|
||||
import python
|
||||
|
||||
from ControlFlowNode f, Context ctx, Value v, ControlFlowNode origin
|
||||
where
|
||||
f.pointsTo(ctx, v, origin) and
|
||||
f.getLocation().getFile().getBaseName() = "test.py"
|
||||
select f.getLocation(), f.toString(), ctx, v
|
||||
@@ -0,0 +1,2 @@
|
||||
semmle-extractor-options: -p ../../lib/ --max-import-depth=3
|
||||
optimize: true
|
||||
@@ -0,0 +1,7 @@
|
||||
from typing import Optional, Set
|
||||
|
||||
def foo(x:Optional[int]) -> int:
|
||||
pass
|
||||
|
||||
def bar(s:set)->Set:
|
||||
pass
|
||||
29
python/ql/test/3/library-tests/lib/typing.py
Normal file
29
python/ql/test/3/library-tests/lib/typing.py
Normal file
@@ -0,0 +1,29 @@
|
||||
#Fake typing module for testing.
|
||||
|
||||
class ComplexMetaclass(type):
|
||||
|
||||
def __new__(self):
|
||||
pass
|
||||
|
||||
class ComplexBaseClass(metaclass=ComplexMetaclass):
|
||||
|
||||
def __new__(self):
|
||||
pass
|
||||
|
||||
class _Optional(ComplexBaseClass, extras=...):
|
||||
|
||||
def __new__(self):
|
||||
pass
|
||||
|
||||
Optional = _Optional("Optional")
|
||||
|
||||
class Collections(ComplexBaseClass, extras=...):
|
||||
pass
|
||||
|
||||
class Set(Collections):
|
||||
pass
|
||||
|
||||
class List(Collections):
|
||||
pass
|
||||
|
||||
Optional
|
||||
Reference in New Issue
Block a user