-
-
Notifications
You must be signed in to change notification settings - Fork 674
Fix sageinspect for Python 3.14 #41032
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Fix sageinspect for Python 3.14 #41032
Conversation
…SpecVisitor In Python 3.14, the AST representation was fully unified to use ast.Constant nodes for all literal values (numbers, strings, booleans, None). Previously, Python 3.8-3.13 still generated legacy node types (ast.Num, ast.Str, ast.NameConstant) for backward compatibility. The SageArgSpecVisitor class had visit methods for the legacy node types but was missing visit_Constant(), causing it to return None for all constant default argument values when parsing function signatures on Python 3.14. This fix adds the visit_Constant() method to properly handle the unified AST representation, allowing correct extraction of default argument values like base=0 in Integer.__init__(self, x=None, base=0). Fixes: #<issue_number> (if applicable)
- Old format: <ast.Assign object at ...> contains "Assign" - New format: Assign(targets=[...], ...) starts with "Assign"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes compatibility issues in sageinspect
for Python 3.14, addressing changes in AST representation and string formatting. Python 3.14 unified all literal values to use ast.Constant
nodes and modified the output format for AST objects.
- Adds
visit_Constant()
method to handle unified AST representation in Python 3.14 - Updates test docstring to accommodate changed AST object string representation
- Ensures proper extraction of default argument values from function signatures
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Documentation preview for this PR (built with commit 95311c9; changes) is ready! 🎉 |
Removed visit_NameConstant and visit_Num methods from SageArgSpecVisitor class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: user202729 <[email protected]>
@user202729 Can I set positive review? |
1.In Python 3.14, the AST representation was fully unified to use
ast.Constant
nodes for all literal values (numbers, strings, booleans, None). Previously, Python 3.8-3.13 still generated legacy node types (ast.Num
,ast.Str
,ast.NameConstant
) for backward compatibility.The
SageArgSpecVisitor
class had visit methods for the legacy node types but was missingvisit_Constant()
, causing it to return None for all constant default argument values when parsing function signatures on Python 3.14.This fix adds the
visit_Constant()
method to properly handle the unified AST representation, allowing correct extraction of default argument values like base=0 inInteger.__init__(self, x=None, base=0)
.2. In line 464, The output format is changed in python 3.14
<ast.Assign object at ...>
contains "Assign"Assign(targets=[...], ...)
starts with "Assign"📝 Checklist
⌛ Dependencies
#41028 (part)