Skip to content

feat: Add PEP 695 type parameter syntax support#124

Open
yaskhan wants to merge 2 commits intomainfrom
feat/pep-695-type-params-12398693319957445264
Open

feat: Add PEP 695 type parameter syntax support#124
yaskhan wants to merge 2 commits intomainfrom
feat/pep-695-type-params-12398693319957445264

Conversation

@yaskhan
Copy link
Owner

@yaskhan yaskhan commented Mar 3, 2026

Closes the issue requesting support for PEP 695 type parameter syntax by modifying the transpiler to parse new AST type_params attributes on classes, functions, and TypeAliases, mapping them natively to V generics. Includes backwards compatibility for Python < 3.12 via safe getattr extraction.


PR created automatically by Jules for task 12398693319957445264 started by @yaskhan

* Extract `type_params` from `ast.ClassDef` in `visit_ClassDef` (`classes.py`).
* Extract `type_params` for standalone functions in `_generate_function_for_struct` (`functions.py`).
* Support `ParamSpec` and `TypeVarTuple` alongside `TypeVar` in `visit_TypeAlias` (`variables.py`).
* Gracefully use `getattr` to safely access new AST node types for Python < 3.12 compatibility.
* Mark PEP 695 task as completed in `todo2.md`.

Co-authored-by: yaskhan <3676373+yaskhan@users.noreply.github.com>
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

* Safely extract `type_params` from `ast.ClassDef`, `ast.FunctionDef`, and `ast.TypeAlias` using `getattr(node, 'type_params')` instead of direct access, satisfying mypy static type checking for Python < 3.12 compatibility.
* Use `getattr(param, 'name')` to avoid attr-defined errors when extracting the type parameter name.

Co-authored-by: yaskhan <3676373+yaskhan@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant