archlinuxcn / lilac

Lilac is the build bot for archlinuxcn
GNU General Public License v3.0
113 stars 40 forks source link

[RFC] pretty style #143

Closed holymonson closed 4 years ago

holymonson commented 4 years ago

sorry 各位,感觉这个代码库有点乱,所以提个建议:统一用black命令(请自行安装)格式化代码,会好看很多。以后也可以用pre-commitflake8在提交前自动检查格式。

这个PR只是看看效果,因为改动太多,所以还是由member提交吧。

P.S. 要求用 type annotation 的 python 库不多,你们也用了;强制规范 coding style 的库不少,你们居然没要求。。

petronny commented 4 years ago

是有格式要求的。

不过有点区别,比如缩进是2个空格,你这个格式化给改成4个了,所以显得改动多。 建议你设置成2空格缩进后重格式化一遍,剩下的diff就比较好看了。

lilydjwg commented 4 years ago

用不用某个工具,不在于别人用得多不多,而在于它对我们的项目有没有意义。

holymonson commented 4 years ago

可能有点误会了,blackyapf自动格式化工具flake8格式检查工具

自动格式化工具的意义,不是让大家去适应它,而是相反,它自己会处理好。无论喜欢用'还是",列表一行写完还是分行写,都没有关系,想怎么写就怎么写,完全不需要注意风格;只要在 commit 前运行一下black,就自动修正了。(我个人用vscode是设置了保存时都会自动格式化,所以根本上是透明的。)

这样的好处是,无论多少个人协作,大家 提交 的风格是一致的,不会有些PR用'、有些用"。尤其是对于新来的人,不熟悉旧有风格,久了就会乱。

yan12125 commented 4 years ago

black不打算支援2 spaces indentation [1]。還是換個工具吧。

[1] https://github.com/psf/black/issues/378

lilydjwg commented 4 years ago

自动格式化工具我更不打算使用了,因为总是会有意料之外的修改。格式检查工具我还可以告诉它说这里比较特殊,你就别操心了。自动格式化工具完全没办法……

lilydjwg commented 4 years ago

一些典型的不能自动格式化的内容包括:

lilydjwg commented 4 years ago

自动格式化工具的本质,就是让大家去适应它,因为它还远没有智能到理解某种排版是不是为了强调,更何况何为美。它不可能反过来适应人类的阅读习惯和审美。

yan12125 commented 4 years ago

依云 notifications@github.com 於 2020年4月10日 週五 下午10:11寫道:

自动格式化工具我更不打算使用了,因为总是会有意料之外的修改。格式检查工具我还可以告诉它说这里比较特殊,你就别操心了。自动格式化工具完全没办法……

For C/C++, clang-format can provide automatic reformatting while preserving special formats in some lines with indicators clang-format off and clang-format on. Maybe a Python tool can also do that. clang-format also provides numerous style tunables to fit different flavors. Examples are indentation style, curly bracket placements, etc [1]. It is an ideal automatic reformatting tool for me. Unfortunately I don't think it can be used on Python LOL.

[1] https://clang.llvm.org/docs/ClangFormatStyleOptions.html

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

holymonson commented 4 years ago

既然大家比较喜欢现在这样,那是我杞人忧天了。