Conversation
- Added a preprocessor to CompatibilityLayer to mangle PEP 696 [T = Default] syntax into PEP 695 compatible [T: __py2v_def__Default] on Python < 3.13. - Updated TranslatorBase to maintain a generic_info registry for classes, functions, and type aliases. - Enhanced map_python_type_to_v and _map_ast_type in py2v_transpiler/models/v_types.py to support PEP 696 defaults by filling in missing generic arguments. - Updated translator mixins to leverage the new default-aware type mapping. - Improved variable initialization in AnnotationsMixin to correctly handle generic types with applied defaults. - Added comprehensive tests for PEP 696 features. 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. |
- Added support for PEP 696 type parameter defaults in classes, functions, and type aliases. - Implemented a preprocessor in CompatibilityLayer to handle Python 3.13+ generic default syntax on older versions. - Fixed a regression in the preprocessor that incorrectly mangled keyword arguments (e.g., file=sys.stderr). - Enhanced map_python_type_to_v to apply defaults when generic types are used with missing arguments. - Updated translator mixins to support the new default-aware type mapping. - Improved zero-initialization of variables with generic types in AnnotationsMixin. - Added comprehensive unit tests for PEP 696 features. Co-authored-by: yaskhan <3676373+yaskhan@users.noreply.github.com>
|
Pull request #245 has conflicts that needs to be resolved. |
Implemented support for PEP 696 (Type Variable Defaults) in the Python to V transpiler.
Key changes:
_preprocess_type_parameter_defaultstoCompatibilityLayerto support Python 3.13+ syntax[T = int]on older Python versions by mangling it to a parsable format.generic_infotoTranslatorBaseto track generic parameters and their defaults for symbols.map_python_type_to_vand its internal AST visitor to apply defaults when a generic type is used with missing or partial arguments.ClassesMixin,FunctionsMixin, andTypeAliasMixinto extract and register default type parameters.AnnotationsMixinto correctly zero-initialize variables of generic types that now resolve to concrete V types due to default application.py2v_transpiler/tests/test_pep696.pycovering various use cases.Note: There is a known regression in advanced PEP 695 Callable unpacking tests that needs further investigation.
Fixes #158
PR created automatically by Jules for task 13720066664418113791 started by @yaskhan