mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Python: Add test
This commit is contained in:
18
python/ql/test/library-tests/PEP695/test.expected
Normal file
18
python/ql/test/library-tests/PEP695/test.expected
Normal file
@@ -0,0 +1,18 @@
|
||||
type_vars_without_bound
|
||||
| test.py:1:8:1:9 | TypeVar | T1 | TypeAlias T |
|
||||
| test.py:3:7:3:8 | TypeVar | T6 | Function f |
|
||||
| test.py:5:9:5:11 | TypeVar | T10 | Class C |
|
||||
type_vars_with_bound
|
||||
| test.py:1:12:1:17 | TypeVar | T2 | E1 | TypeAlias T |
|
||||
| test.py:3:11:3:16 | TypeVar | T7 | E2 | Function f |
|
||||
| test.py:5:14:5:20 | TypeVar | T11 | E3 | Class C |
|
||||
type_var_tuples
|
||||
| test.py:1:20:1:22 | TypeVarTuple | T3 | TypeAlias T |
|
||||
| test.py:3:19:3:21 | TypeVarTuple | T8 | Function f |
|
||||
| test.py:5:23:5:26 | TypeVarTuple | T12 | Class C |
|
||||
param_specs
|
||||
| test.py:1:25:1:28 | ParamSpec | T4 | TypeAlias T |
|
||||
| test.py:3:24:3:27 | ParamSpec | T9 | Function f |
|
||||
| test.py:5:29:5:33 | ParamSpec | T13 | Class C |
|
||||
type_aliases
|
||||
| test.py:1:1:1:34 | TypeAlias | T | T5 |
|
||||
5
python/ql/test/library-tests/PEP695/test.py
Normal file
5
python/ql/test/library-tests/PEP695/test.py
Normal file
@@ -0,0 +1,5 @@
|
||||
type T[T1, T2: E1, *T3, **T4] = T5
|
||||
|
||||
def f[T6, T7: E2, *T8, **T9](): ...
|
||||
|
||||
class C[T10, T11: E3, *T12, **T13]: ...
|
||||
36
python/ql/test/library-tests/PEP695/test.ql
Normal file
36
python/ql/test/library-tests/PEP695/test.ql
Normal file
@@ -0,0 +1,36 @@
|
||||
import python
|
||||
|
||||
string pretty_name(AstNode n) {
|
||||
result = "Function " + n.(Function).getName()
|
||||
or
|
||||
result = "Class " + n.(ClassExpr).getName()
|
||||
or
|
||||
result = "TypeAlias " + n.(TypeAlias).getName().getId()
|
||||
}
|
||||
|
||||
query predicate type_vars_without_bound(TypeVar tv, string name, string parent) {
|
||||
tv.getName().getId() = name and
|
||||
not exists(tv.getBound()) and
|
||||
parent = pretty_name(tv.getParent().getParent())
|
||||
}
|
||||
|
||||
query predicate type_vars_with_bound(TypeVar tv, string name, string bound, string parent) {
|
||||
tv.getName().getId() = name and
|
||||
bound = tv.getBound().(Name).getId() and
|
||||
parent = pretty_name(tv.getParent().getParent())
|
||||
}
|
||||
|
||||
query predicate type_var_tuples(TypeVarTuple tvt, string name, string parent) {
|
||||
tvt.getName().getId() = name and
|
||||
parent = pretty_name(tvt.getParent().getParent())
|
||||
}
|
||||
|
||||
query predicate param_specs(ParamSpec ps, string name, string parent) {
|
||||
ps.getName().getId() = name and
|
||||
parent = pretty_name(ps.getParent().getParent())
|
||||
}
|
||||
|
||||
query predicate type_aliases(TypeAlias ta, string name, string value) {
|
||||
ta.getName().getId() = name and
|
||||
value = ta.getValue().(Name).getId()
|
||||
}
|
||||
Reference in New Issue
Block a user