Skip to content

Commit 28f8874

Browse files
authored
Merge pull request github#17688 from github/tausbn/python-3.13-default-type-parser-support
Python: Add support for type parameter defaults
2 parents d4e0cb2 + 417e60a commit 28f8874

File tree

24 files changed

+36226
-32551
lines changed

24 files changed

+36226
-32551
lines changed

python/downgrades/5af903da088e3746aa283700a43a779302453523/old.dbscheme

Lines changed: 1236 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// We must wrap the DB types, as these cannot appear in argument lists
2+
class TypeParameter_ extends @py_type_parameter {
3+
string toString() { result = "TypeParameter" }
4+
}
5+
6+
class Expr_ extends @py_expr {
7+
string toString() { result = "Expr" }
8+
}
9+
10+
class ExprParent_ extends @py_expr_parent {
11+
string toString() { result = "ExprParent" }
12+
}
13+
14+
class TypeVar_ extends @py_TypeVar, TypeParameter_ {
15+
override string toString() { result = "TypeVar" }
16+
}
17+
18+
class TypeVarTuple_ extends @py_TypeVarTuple, TypeParameter_ {
19+
override string toString() { result = "TypeVarTuple" }
20+
}
21+
22+
class ParamSpec_ extends @py_ParamSpec, TypeParameter_ {
23+
override string toString() { result = "ParamSpec" }
24+
}
25+
26+
// From the dbscheme:
27+
// py_exprs(unique int id : @py_expr,
28+
// int kind: int ref,
29+
// int parent : @py_expr_parent ref,
30+
// int idx : int ref);
31+
query predicate py_exprs_without_type_parameter_defaults(
32+
Expr_ id, int kind, ExprParent_ parent, int idx
33+
) {
34+
py_exprs(id, kind, parent, idx) and
35+
// From the dbscheme
36+
// /* <Field> ParamSpec.default = 2, expr */
37+
// /* <Field> TypeVar.default = 3, expr */
38+
// /* <Field> TypeVarTuple.default = 2, expr */
39+
(parent instanceof ParamSpec_ implies idx != 2) and
40+
(parent instanceof TypeVar_ implies idx != 3) and
41+
(parent instanceof TypeVarTuple_ implies idx != 2)
42+
}

0 commit comments

Comments
 (0)