Visitar URL original
Python: Allow trailing commas in type parameter lists by jketema · Pull Request #22743 · github/codeql · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Python: Allow trailing commas in type parameters
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
  • Loading branch information
jketema and Copilot committed Oct 6, 2026
commit 199a93f4e09bd561e11f76de9bd7512568949d2b
2 changes: 1 addition & 1 deletion python/extractor/semmle/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#Semantic version of extractor.
#Update this if any changes are made
VERSION = "7.2.0"
VERSION = "7.2.1"

PY_EXTENSIONS = ".py", ".pyw"

Expand Down
88 changes: 88 additions & 0 deletions python/extractor/tests/parser/type_parameters_new.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
Module: [1, 0] - [12, 0]
body: [
TypeAlias: [1, 0] - [3, 5]
name:
Name: [1, 5] - [1, 10]
variable: Variable('Alias', None)
ctx: Store
type_parameters: [
TypeVar: [2, 4] - [2, 5]
name:
Name: [2, 4] - [2, 5]
variable: Variable('T', None)
ctx: Store
bound: None
default: None
]
value:
Name: [3, 4] - [3, 5]
variable: Variable('T', None)
ctx: Load
Assign: [5, 0] - [7, 4]
targets: [
Name: [5, 4] - [5, 12]
variable: Variable('function', None)
ctx: Store
]
value:
FunctionExpr: [5, 0] - [7, 4]
name: 'function'
args:
arguments
defaults: []
kw_defaults: []
annotations: []
varargannotation: None
kwargannotation: None
kw_annotations: []
returns: None
inner_scope:
Function: [5, 0] - [7, 4]
name: 'function'
type_parameters: [
TypeVar: [6, 4] - [6, 5]
name:
Name: [6, 4] - [6, 5]
variable: Variable('T', None)
ctx: Store
bound: None
default: None
]
args: []
vararg: None
kwonlyargs: []
kwarg: None
body: [
Expr: [7, 5] - [7, 8]
value:
Ellipsis: [7, 5] - [7, 8]
]
Assign: [9, 0] - [11, 2]
targets: [
Name: [9, 6] - [9, 11]
variable: Variable('Class', None)
ctx: Store
]
value:
ClassExpr: [9, 0] - [11, 2]
name: 'Class'
type_parameters: [
TypeVar: [10, 4] - [10, 5]
name:
Name: [10, 4] - [10, 5]
variable: Variable('T', None)
ctx: Store
bound: None
default: None
]
bases: []
keywords: []
inner_scope:
Class: [9, 0] - [11, 2]
name: 'Class'
body: [
Expr: [11, 3] - [11, 6]
value:
Ellipsis: [11, 3] - [11, 6]
]
]
11 changes: 11 additions & 0 deletions python/extractor/tests/parser/type_parameters_new.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
type Alias[
T,
] = T

def function[
T,
](): ...

class Class[
T,
]: ...
1 change: 1 addition & 0 deletions python/extractor/tsg-python/tsp/grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,7 @@ module.exports = grammar({
type_parameters: $ => seq(
'[',
commaSep1(field('type_parameter', $._type_parameter)),
optional(','),
Comment thread
jketema marked this conversation as resolved.
']'
),

Expand Down
12 changes: 12 additions & 0 deletions python/extractor/tsg-python/tsp/src/grammar.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading