Skip to content

Commit 199a93f

Browse files
jketemaCopilot
andcommitted
Python: Allow trailing commas in type parameters
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 89844db commit 199a93f

6 files changed

Lines changed: 32843 additions & 32668 deletions

File tree

‎python/extractor/semmle/util.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#Semantic version of extractor.
1212
#Update this if any changes are made
13-
VERSION = "7.2.0"
13+
VERSION = "7.2.1"
1414

1515
PY_EXTENSIONS = ".py", ".pyw"
1616

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
Module: [1, 0] - [12, 0]
2+
body: [
3+
TypeAlias: [1, 0] - [3, 5]
4+
name:
5+
Name: [1, 5] - [1, 10]
6+
variable: Variable('Alias', None)
7+
ctx: Store
8+
type_parameters: [
9+
TypeVar: [2, 4] - [2, 5]
10+
name:
11+
Name: [2, 4] - [2, 5]
12+
variable: Variable('T', None)
13+
ctx: Store
14+
bound: None
15+
default: None
16+
]
17+
value:
18+
Name: [3, 4] - [3, 5]
19+
variable: Variable('T', None)
20+
ctx: Load
21+
Assign: [5, 0] - [7, 4]
22+
targets: [
23+
Name: [5, 4] - [5, 12]
24+
variable: Variable('function', None)
25+
ctx: Store
26+
]
27+
value:
28+
FunctionExpr: [5, 0] - [7, 4]
29+
name: 'function'
30+
args:
31+
arguments
32+
defaults: []
33+
kw_defaults: []
34+
annotations: []
35+
varargannotation: None
36+
kwargannotation: None
37+
kw_annotations: []
38+
returns: None
39+
inner_scope:
40+
Function: [5, 0] - [7, 4]
41+
name: 'function'
42+
type_parameters: [
43+
TypeVar: [6, 4] - [6, 5]
44+
name:
45+
Name: [6, 4] - [6, 5]
46+
variable: Variable('T', None)
47+
ctx: Store
48+
bound: None
49+
default: None
50+
]
51+
args: []
52+
vararg: None
53+
kwonlyargs: []
54+
kwarg: None
55+
body: [
56+
Expr: [7, 5] - [7, 8]
57+
value:
58+
Ellipsis: [7, 5] - [7, 8]
59+
]
60+
Assign: [9, 0] - [11, 2]
61+
targets: [
62+
Name: [9, 6] - [9, 11]
63+
variable: Variable('Class', None)
64+
ctx: Store
65+
]
66+
value:
67+
ClassExpr: [9, 0] - [11, 2]
68+
name: 'Class'
69+
type_parameters: [
70+
TypeVar: [10, 4] - [10, 5]
71+
name:
72+
Name: [10, 4] - [10, 5]
73+
variable: Variable('T', None)
74+
ctx: Store
75+
bound: None
76+
default: None
77+
]
78+
bases: []
79+
keywords: []
80+
inner_scope:
81+
Class: [9, 0] - [11, 2]
82+
name: 'Class'
83+
body: [
84+
Expr: [11, 3] - [11, 6]
85+
value:
86+
Ellipsis: [11, 3] - [11, 6]
87+
]
88+
]
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
type Alias[
2+
T,
3+
] = T
4+
5+
def function[
6+
T,
7+
](): ...
8+
9+
class Class[
10+
T,
11+
]: ...

‎python/extractor/tsg-python/tsp/grammar.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,7 @@ module.exports = grammar({
638638
type_parameters: $ => seq(
639639
'[',
640640
commaSep1(field('type_parameter', $._type_parameter)),
641+
optional(','),
641642
']'
642643
),
643644

‎python/extractor/tsg-python/tsp/src/grammar.json‎

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)