chore: update max line length - #63
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
| target-version = "py312" | ||
|
|
||
| [tool.ruff.lint] | ||
| select = ["E", "F", "I", "B", "UP"] |
There was a problem hiding this comment.
我在文档中看到
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
# McCabe complexity (`C901`) by default.
这个E、F、I、B、UP是什么?
There was a problem hiding this comment.
select = ["E", "F", "I", "B", "UP"] 代表的是 Ruff 所启用规则的 规则类别前缀,每个字母代表一个来源或一类 lint 规则。E是pycodestyle中的Error,pycodestyle是一个检查python代码是否符合PEP8中的一些样式约定的工具。E是所有错误类规则的前缀,表示启用了所有类型的错误的检查。F是Pyflakes,用来检查python源文件中是否存在错误的库。I是isort,用来自动排序import文件的顺序。B是flake8-bugbear,是一个查找程序中可能存在的bug和设计问题的库,包括了pyflakes和pycodestyle中不包含的警告。UP是pyupgrade,用于建议自动升级现代 Python 语法。
There was a problem hiding this comment.
我在 https://docs.astral.sh/ruff/rules/ 看到了很多rule,当前的这个选型是怎么判断出来的?
There was a problem hiding this comment.
这些是用的比较多的,是比较常用的一些类型,是一个比较常用的组合。
There was a problem hiding this comment.
If you're just getting started with Ruff, the default rule set is a great place to start.
我看到了ruff的推荐,说明一下为什么这么选择,“是一个比较常用的组合”这一句话无法接受。
你可以一条一条说明,也可以给出一个具体的现有项目是这么选择的例子。
如果不行,就换成ruff推荐的吧。
There was a problem hiding this comment.
这是结合了ChatGPT和知乎上一些文章得到的一套常见规则。我之前看过torch的文档,他们的文档相当来说特别成熟,他们的pyproject.toml中使用了上述所有的规则(Isort是单独使用了,没有通过ruff)。我觉得前期项目中使用这些规则应该是比较合适的。如果后续有其他的规则还可以再添加。
There was a problem hiding this comment.
无论是知乎上的文章,还是pytorch的pyproject,都并不是你目前这个配置。
There was a problem hiding this comment.
但是这几个配置确实挺常用的,知乎上那个少了Isort(排列import顺序的库),torch中Isort是单独拿出来的,torch里面配置太多了,所以只选取了部分。那改成ruff官方推荐的配置吗?
There was a problem hiding this comment.
换成ruff默认的吧。
且不说知乎上的回答做选型依据不合适,你提供的回答中,目前的版本中相比知乎回答中多了I和B少了W。
hzhangxyz
left a comment
There was a problem hiding this comment.
做的挺好的,有一些疑问见详情。考虑到之前的经验,这里申明一下,里面的一些问句是真的问句,不是反问。这个pr中,特别是规则那地方,以后最好少修改,所以我们现在尽量慎重并确认没啥问题。
| target-version = "py312" | ||
|
|
||
| [tool.ruff.lint] | ||
| select = ["E", "F", "I", "B", "UP"] |
There was a problem hiding this comment.
我在 https://docs.astral.sh/ruff/rules/ 看到了很多rule,当前的这个选型是怎么判断出来的?
| target-version = "py312" | ||
|
|
||
| [tool.ruff.lint] | ||
| select = ["E", "F", "I", "B", "UP"] |
There was a problem hiding this comment.
If you're just getting started with Ruff, the default rule set is a great place to start.
我看到了ruff的推荐,说明一下为什么这么选择,“是一个比较常用的组合”这一句话无法接受。
你可以一条一条说明,也可以给出一个具体的现有项目是这么选择的例子。
如果不行,就换成ruff推荐的吧。
This commit is squashed by: chore: update max line length chore: remove legacy yapf configuration chore: remove legacy pylint configuration ci(pytest): add matrix testing for multiple python versions and os ci(workflow): restrict GITHUB_TOKEN permissions to contents:read chore: remove legacy pylint configuration ci(pytest): add support for python=3.13 style: correct unconventional YAML and adjust print statements fix: update the rule of ruff fix: update the rule of ruff Use python only in pytest action script to show python information. Temporarily recovery python codes.
a4ecfe5 to
3ab37a3
Compare
3ab37a3 to
0189161
Compare
pyproject.tomlwith ruff and applied Ruff formatter with 'line-length=100'