[Fix] use `py_compile` for pyi file syntax check by megemini · Pull Request #71872 · PaddlePaddle/Paddle
你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册。
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 a syntax check issue in .pyi files by replacing the use of ast.parse with py_compile, ensuring that syntax errors are reliably caught. Key changes include:
- Removing the "limit" parameter and using an infinite loop to repeatedly attempt syntax checking.
- Replacing ast.parse with py_compile.compile for validating file syntax.
- Updating error handling logic to delete lines causing syntax errors.
Comments suppressed due to low confidence (1)
tools/gen_pybind11_stub.py:15
- The code uses traceback.format_exc(), but there is no import for the traceback module. Please add 'import traceback' to ensure proper functionality.
from __future__ import annotations
Comment on lines 335 to 336
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The removal of the loop limit may result in an infinite loop if a syntax error persists and the file never becomes fully compilable. Consider reintroducing a maximum iteration count or an alternative escape strategy.
| while True: | |
| max_iterations = 10 | |
| iteration_count = 0 | |
| while iteration_count < max_iterations: |
Copilot uses AI. Check for mistakes.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@megemini 顺师傅看看这里还要改么?看着是有点合理的,不过问题不大,不改的话就直接 merge 了
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
那我把 limit 加回去吧 ~ 🫣
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters

