Skip to content
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

docs 代码风格检查工具对齐 Paddle #6158

Closed
SigureMo opened this issue Sep 4, 2023 · 0 comments · Fixed by #6274
Closed

docs 代码风格检查工具对齐 Paddle #6158

SigureMo opened this issue Sep 4, 2023 · 0 comments · Fixed by #6274
Labels
good first issue Good for newcomers HappyOpenSource 快乐开源活动issue与PR

Comments

@SigureMo
Copy link
Member

SigureMo commented Sep 4, 2023

Motivation

Paddle 主 repo 由于有着大量的 C++ 和 Python 代码,因此代码风格检查工具的使用是必不可少的。Paddle repo 主要使用 pre-commit 作为管理工具,用于在 git commit 之前自动运行代码风格检查工具(见 .pre-commit-config.yaml,当然也可以参考 代码风格检查指南,但这里内容不保证是最新的),以保证提交的代码风格符合规范。

随着 Paddle repo 中基础设施的不断完善,我们的代码风格检查工具也经历了几次升级,而其他下游 repo 大多没有及时跟进,会导致开发者在不同 repo 需要使用不同的代码风格,开发体验不一致,这其中就包含了 docs repo。因此本任务的目标就是更新 docs repo 代码风格检查工具,使之对齐 Paddle repo

Task details

  • 升级 docs repo 中现有的代码风格检查工具版本(见 .pre-commit-config.yaml),使之对齐 Paddle repo,这包含
    • black
    • pre-commit/pre-commit-hooks(监控全部文件)
    • Lucas-C/pre-commit-hooks(监控全部文件)
  • 补全 Paddle 中启用但 docs 中未引入的 pre-commit hook,这包含
    • isort(请使用 ruff 中的 isort 功能替代)
    • ruff
  • 移除重复的 pre-commit hooks,这包含
    • forbid-crlf(包含于 remove-crlf
    • forbid-tabs(包含于 remove-tabs
    • check-whitespace-between-cn-and-en-char(包含于 insert-whitespace-between-cn-and-en-char
  • 注意更新 hook 后要同步修复该 hook 所暴露出的存量问题
  • 【进阶任务】优化 CI 显示效果,只运行一次 pre-commit,可参考 [pre-commit] make pre-commit a single pipeline Paddle#43469[CodeStyle] add more information when codestyle check failed Paddle#47116

Important

本任务需要任务规划的拆解能力,虽然 docs 中代码不多,但每个工具的引入都需要从配置选择、存量修复、增量检查等多个方面进行考量

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers HappyOpenSource 快乐开源活动issue与PR
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants