Ruff lints the whole repo

未关闭 适合新手
#729 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
68/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
github-actions, python
领域
ci-cd, tooling

调研方向

从 .github/workflows/linters.yaml 开始,检查现有的 Check code style 步骤,然后打开一个 pull request,以确认 Ruff 当前检查哪些文件。更新工作流,使 Ruff 的格式化和 lint 命令仅接收已修改的 Python 文件,并确认在没有 Python 文件发生更改时检查会正常跳过。

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

描述

ℹ️ Please note that the best way to get support for Real Python courses & articles is to join one of our weekly Office Hours calls or in the RP Community Slack.

You can report issues and problems here, but we typically won't be able to provide 1:1 support outside the channels listed above.

Describe the bug

Currently, Ruff lints all the files in the repo, which can be inefficient.

To Reproduce
Steps to reproduce the behavior:

  1. Open a PR and take a look at the Ruff check details.

Expected behavior
Lint only the modified Python files.

Additional context
Proposed update to file .github/workflows/linters.yaml

- name: Check code style
      run: |
        . venv/bin/activate
        if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then
          git fetch origin ${{ github.base_ref }}
          CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}...${{ github.sha }} -- '*.py')
        else
          CHANGED_FILES=$(git diff --name-only HEAD^ -- '*.py')
        fi
        if [ -n "$CHANGED_FILES" ]; then
          python -m ruff format --check $CHANGED_FILES
          python -m ruff check $CHANGED_FILES
        fi
主要语言
Jupyter Notebook
星标
5.2k
派生
5.3k
平均合并
4 天 10 小时
30 天内合并 PR
10

贡献指南

这个仓库没有索引到贡献指南

从这里开始

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

realpython/materials 的其他 Issue

查看 realpython/materials 的全部 Issue

相似的 Issue

更多 DevOps Issue

把新 issue 发到你的邮箱

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