Implement Variance Support for PEP 695 Type Parameters#232
Implement Variance Support for PEP 695 Type Parameters#232
Conversation
Implemented support for explicit covariance (+T) and contravariance (-T) modifiers in PEP 695 type parameter syntax. Key changes: - Added `_preprocess_pep695_variance` to `CompatibilityLayer` to strip variance modifiers before AST parsing, ensuring compatibility with standard Python 3.12+ while preserving metadata. - Updated `PyASTParser` to propagate variance information from the preprocessor to AST nodes. - Modified `ClassesMixin`, `FunctionsMixin`, and `TypeAliasMixin` to emit variance modifiers as `@variance` comments in the generated V code. - Added comprehensive unit tests in `py2v_transpiler/tests/test_variance.py`. - Updated `README.md` to document variance support and the invariance of V generics. - Improved preprocessor to handle `async def` and multi-line headers. - Fixed existing compatibility tests to work with the updated preprocessor. - Verified that Mypy correctly detects variance violations in the original source code. Co-authored-by: yaskhan <3676373+yaskhan@users.noreply.github.com>
|
👋 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 New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
Pull request #232 has conflicts that needs to be resolved. |
Completed the implementation with several improvements: - Robust preprocessor in `CompatibilityLayer` using `re.finditer` and bracket counting to support multi-line headers and `async def`. - Attached variance metadata to AST nodes in `PyASTParser`. - Updated `ClassesMixin`, `FunctionsMixin`, and `TypeAliasMixin` to emit variance information as `@variance` comments in V code. - Added comprehensive unit tests in `py2v_transpiler/tests/test_variance.py`. - Updated `README.md` and `TODO.md`. - Fixed existing compatibility tests. - Verified that all 531 tests pass. Co-authored-by: yaskhan <3676373+yaskhan@users.noreply.github.com>
Implement support for explicit variance modifiers (+T, -T) in PEP 695 type parameter syntax. The modifiers are preserved as metadata comments in the generated V code, providing future-proofing and documentation for V's invariant generics. The implementation includes a robust preprocessing layer to handle multi-line headers and async functions.
Fixes #198
PR created automatically by Jules for task 15320403030881130028 started by @yaskhan