Description of the issue
The Python extractor (CodeQL CLI 2.27.1) fails to parse a trailing comma after the last type parameter, and the file is dropped from analysis. This applies to class, def and type statements. ruff format and Black add this comma whenever they split a long type parameter list, so formatted code runs into it.
class A[
T: int,
U: str, # Syntax Error here
]:
pass
type_parameters in tsg-python/tsp/grammar.js has no optional trailing comma, while CPython's grammar does (type_param_seq: ','.type_param+ [',']). Adding it fixes the error:
type_parameters: $ => seq(
'[',
commaSep1(field('type_parameter', $._type_parameter)),
+ optional(','),
']'
),
Description of the issue
The Python extractor (CodeQL CLI 2.27.1) fails to parse a trailing comma after the last type parameter, and the file is dropped from analysis. This applies to
class,defandtypestatements. ruff format and Black add this comma whenever they split a long type parameter list, so formatted code runs into it.type_parametersintsg-python/tsp/grammar.jshas no optional trailing comma, while CPython's grammar does (type_param_seq: ','.type_param+ [',']). Adding it fixes the error:type_parameters: $ => seq( '[', commaSep1(field('type_parameter', $._type_parameter)), + optional(','), ']' ),