realpython / realpython/python-guide

Recommended autoformatters?

未关闭
#931 5 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
Batchfile
星标
29.8k
派生
5.9k
PR 合并指标
30 天内没有已合并 PR

描述

In the Code Style document https://github.com/realpython/python-guide/blob/master/docs/writing/style.rst there's a small mention of autopep8 which can be used to format code to meet PEP8 standards. But there's at least two other autoformatters (black and yapf) which are as good if not better. There's a blog comparing the three here: https://medium.com/3yourmind/auto-formatters-for-python-8925065f9505
The gist of it is: autopep8 is the most conservative, black is the most opinionated, and yapf is somewhere in between depending on how you configure it.

Should the python guide have an opinion on which auto formatters should be used? In addition to the current mention of autopep8. I think it would be good to expand this section; auto formatters are quite useful and of great interest to developers coming from tools like gofmt and prettier.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 docs/writing/style.rst 中现有的 autopep8 提及处开始,然后查看所链接的 autopep8、black 和 yapf 对比。更新 Code Style 文档,加入关于这些格式化工具的指导以及明确的推荐或比较;该部分应说明开发者如何选择 autoformatter。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
documentation
Issue 类型
文档
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。