Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Python: trailing comma in a PEP 695 type parameter list causes a parse error

Open Beginner friendly
#22,739 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
88/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
compilers

Research direction

Start in tsg-python/tsp/grammar.js at the type_parameters rule, then compare its comma handling with the linked CPython grammar. Done means the Python extractor accepts trailing commas in PEP 695 type parameter lists for class, def, and type statements, including the formatted example shown.

Written by the indexing model from the issue text.

Description

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(','),
       ']'
     ),
Dominant language
CodeQL
Stars
10.1k
Forks
2.1k
Avg merge
2d 9h
Merged PRs (30d)
147

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from github/codeql

All issues in github/codeql

Similar issues

More Compilers issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.