Skip to content

chore: update max line length - #63

Merged
hzhangxyz merged 3 commits into
mainfrom
chore/update-line-length
Sep 2, 2025
Merged

chore: update max line length#63
hzhangxyz merged 3 commits into
mainfrom
chore/update-line-length

Conversation

@gausshj

@gausshj gausshj commented Aug 29, 2025

Copy link
Copy Markdown
Collaborator
  • Updated pyproject.toml with ruff and applied Ruff formatter with 'line-length=100'
  • Removed conflicting yapf hook, switched to Ruff format and lint.
  • Improve readability

@codecov

codecov Bot commented Aug 29, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.83333% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
grassmann_tensor/tensor.py 95.83% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Comment thread pyproject.toml Outdated
Comment thread pyproject.toml
Comment thread pyproject.toml
Comment thread pyproject.toml Outdated
Comment thread pyproject.toml Outdated
target-version = "py312"

[tool.ruff.lint]
select = ["E", "F", "I", "B", "UP"]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我在文档中看到

# 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是什么?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 语法。

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我在 https://docs.astral.sh/ruff/rules/ 看到了很多rule,当前的这个选型是怎么判断出来的?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这些是用的比较多的,是比较常用的一些类型,是一个比较常用的组合。

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're just getting started with Ruff, the default rule set is a great place to start.

我看到了ruff的推荐,说明一下为什么这么选择,“是一个比较常用的组合”这一句话无法接受。

你可以一条一条说明,也可以给出一个具体的现有项目是这么选择的例子。

如果不行,就换成ruff推荐的吧。

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这是结合了ChatGPT和知乎上一些文章得到的一套常见规则。我之前看过torch的文档,他们的文档相当来说特别成熟,他们的pyproject.toml中使用了上述所有的规则(Isort是单独使用了,没有通过ruff)。我觉得前期项目中使用这些规则应该是比较合适的。如果后续有其他的规则还可以再添加。

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

无论是知乎上的文章,还是pytorch的pyproject,都并不是你目前这个配置。

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

但是这几个配置确实挺常用的,知乎上那个少了Isort(排列import顺序的库),torch中Isort是单独拿出来的,torch里面配置太多了,所以只选取了部分。那改成ruff官方推荐的配置吗?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

换成ruff默认的吧。

且不说知乎上的回答做选型依据不合适,你提供的回答中,目前的版本中相比知乎回答中多了I和B少了W。

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的,已经在54d0556中修改了。

@hzhangxyz hzhangxyz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

做的挺好的,有一些疑问见详情。考虑到之前的经验,这里申明一下,里面的一些问句是真的问句,不是反问。这个pr中,特别是规则那地方,以后最好少修改,所以我们现在尽量慎重并确认没啥问题。

Comment thread .pre-commit-config.yaml
Comment thread pyproject.toml Outdated
Comment thread pyproject.toml Outdated
target-version = "py312"

[tool.ruff.lint]
select = ["E", "F", "I", "B", "UP"]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我在 https://docs.astral.sh/ruff/rules/ 看到了很多rule,当前的这个选型是怎么判断出来的?

Comment thread .github/workflows/pytest.yml Fixed
Comment thread pyproject.toml
Comment thread pyproject.toml Outdated
target-version = "py312"

[tool.ruff.lint]
select = ["E", "F", "I", "B", "UP"]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're just getting started with Ruff, the default rule set is a great place to start.

我看到了ruff的推荐,说明一下为什么这么选择,“是一个比较常用的组合”这一句话无法接受。

你可以一条一条说明,也可以给出一个具体的现有项目是这么选择的例子。

如果不行,就换成ruff推荐的吧。

Comment thread .github/workflows/pytest.yml Outdated
Comment thread .github/workflows/pytest.yml Outdated
Comment thread .github/workflows/pytest.yml Outdated
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.
@hzhangxyz
hzhangxyz force-pushed the chore/update-line-length branch from a4ecfe5 to 3ab37a3 Compare September 2, 2025 12:05
@hzhangxyz
hzhangxyz force-pushed the chore/update-line-length branch from 3ab37a3 to 0189161 Compare September 2, 2025 12:15
@hzhangxyz
hzhangxyz merged commit f3833aa into main Sep 2, 2025
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants