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

Use loguru and appdirs to replace logging and hard coded path #82

Merged
merged 16 commits into from
Oct 16, 2023

Conversation

zrr1999
Copy link
Contributor

@zrr1999 zrr1999 commented Oct 14, 2023

  1. 使用 loguru 代替 logging,并将compiler中的print替换为日志形式。
  2. 使用 appdirs 获取缓存路径,避免为每个系统单独寻找缓存路径。
  3. 移除 isort 并在 ruff 中加入相应替代配置。

Copy link
Collaborator

@gglin001 gglin001 left a comment

Choose a reason for hiding this comment

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

most looks fine

rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/psf/black
Copy link
Collaborator

Choose a reason for hiding this comment

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

ruff-format 目前可以替代 black 吗?

Using Ruff's formatter (unstable)
https://github.com/astral-sh/ruff-pre-commit#using-ruffs-formatter-unstable

这里是 "unstable" 的状态, 另外这里需要加上

...
  hooks:
    - id: ruff-format

吗?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

这块我也不太确定,我把autoflake的配置给恢复回去了

Copy link
Collaborator

Choose a reason for hiding this comment

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

建议 暂时保留 black 的配置, 可以在后面替换(如果有必要)

Copy link
Collaborator

Choose a reason for hiding this comment

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

另外这里需要加上 ... 吗?

需要的,ruff 和 ruff-format 是两个不同的 hook,ruff 仅仅包含 lint 而不包含 format(https://github.com/astral-sh/ruff-pre-commit/blob/42f98979dbdfcd148dff424477552b8816a7cf01/.pre-commit-hooks.yaml#L4

format 还用 black 吧,ruff 还太早期了 0.0.291 还只是第一个用户可见的版本,距离可用还需要很久的打磨

不过我相信 isort 已经可以替换了,已经打算 ruff 过两天发布 0.1.0 (astral-sh/ruff#7931)就在 Paddle 那边将 isort 替换为 ruff 的 isort 实现

rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/psf/black
Copy link
Collaborator

Choose a reason for hiding this comment

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

另外这里需要加上 ... 吗?

需要的,ruff 和 ruff-format 是两个不同的 hook,ruff 仅仅包含 lint 而不包含 format(https://github.com/astral-sh/ruff-pre-commit/blob/42f98979dbdfcd148dff424477552b8816a7cf01/.pre-commit-hooks.yaml#L4

format 还用 black 吧,ruff 还太早期了 0.0.291 还只是第一个用户可见的版本,距离可用还需要很久的打磨

不过我相信 isort 已经可以替换了,已经打算 ruff 过两天发布 0.1.0 (astral-sh/ruff#7931)就在 Paddle 那边将 isort 替换为 ruff 的 isort 实现

pyproject.toml Outdated
]
ignore = [
"UP015",
"Q000",
Copy link
Collaborator

Choose a reason for hiding this comment

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

这里没有 select Q 为什么要 ignore Q000 呢?

Comment on lines +13 to +14
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.9.1
Copy link
Collaborator

Choose a reason for hiding this comment

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

将 black 加回来并更新为最新版本和使用 mirror 版本(就相当于从 PyPI 下载而不是 clone 源码构建),因为 mirror 版本比 source 版本的优势是通过 mypyc 编译,有更快的速度,也是现在推荐的方式,相关讨论见 psf/black#3405 ,文档见 https://black.readthedocs.io/en/stable/integrations/source_version_control.html

@SigureMo SigureMo merged commit 0478b15 into PFCCLab:main Oct 16, 2023
6 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