-
Notifications
You must be signed in to change notification settings - Fork 66
Fix ast.Expression deprecation warning by using proper constructor #2386
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: main
Are you sure you want to change the base?
Conversation
Co-authored-by: justinchuby <11205048+justinchuby@users.noreply.github.com>
ast.Expression
is invalid
❌ 3 Tests Failed:
View the top 3 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
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 resolves a deprecation warning by updating the creation of an ast.Expression object to use the correct parameter and then manually setting the lineno and col_offset attributes.
- Changed the instantiation of ast.Expression to use the body parameter.
- Added manual assignment of lineno and col_offset to preserve source location information.
Comments suppressed due to low confidence (1)
onnxscript/converter.py:457
- [nitpick] Consider adding a brief comment explaining that the lineno and col_offset attributes are set manually to address the deprecation warning for clarity and future maintenance.
expr = ast.Expression(body=expr)
This PR fixes a deprecation warning in
onnxscript/converter.py
whereast.Expression
was being called with invalid keyword arguments:Problem
The code at line 457 was using:
The
ast.Expression
constructor doesn't acceptlineno
andcol_offset
as keyword arguments. This produces a deprecation warning that will become an error in Python 3.15.Solution
Changed to use the proper API:
This approach:
body
parameter in the constructorTesting
Fixes #2114.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.