Skip to content

build(ruff): require guard clauses instead of else after return - #28

Merged
furedea merged 1 commit into
mainfrom
build/require-guard-clauses
Nov 15, 2026
Merged

furedea merged 1 commit into
mainfrom
build/require-guard-clauses

Conversation

@furedea-agent

@furedea-agent furedea-agent Bot commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

概要

else を return / raise / continue / break の後ろに置くコードを,散文のルールではなくリンターで拒否するようにします.

pyproject.toml の [tool.ruff.lint] select に RET505,RET506,RET507,RET508 の4つだけを追加しました(RET グループ全体は有効化していません).固定版 ruff 0.15.11 で確認したところ,4つとも preview 限定ではないため,通常のルール ID として追加しています.

Before / After

Before(許可されていた):

if x:
    return 1
else:
    return 2

After(RET505 で拒否される):

if x:
    return 1
return 2

検証

  • 使い捨てのサンプル(if x: return 1 + else: return 2)をリポジトリ内に置き,uv run ruff check が RET505 を報告することを確認しました.サンプルは削除済みで,コミットには含まれません.
  • uv run ruff check: 通過(既存コードに新しい指摘なし)
  • uv run ruff format --check: 通過
  • uv run ty check: 通過
  • uv run pytest -q: 1 passed

Issue はありません.計画からの逸脱もありません.

🤖 Generated with Claude Code

Enable RET505, RET506, RET507 and RET508 so the linter rejects an else
branch after an if block that ends with return, raise, continue or break.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@furedea

furedea commented Nov 15, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-15T05:16:37.103190Z 8899124 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown

Review summary: No findings.

This PR adds RET505, RET506, RET507 and RET508 to [tool.ruff.lint] select. They go in the normal, non-preview section, which is right: these are stable rules and are not affected by explicit-preview-rules. None of the entries in ignore or per-file-ignores cancel them. The only Python sources in the repo are src/main.py and tests/test_main.py, so the risk of new violations is low. This change only touches lint config and doesn't need tests.

🤖 Generated with Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 8899124d65

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@furedea
furedea merged commit 475542f into main Nov 15, 2026
18 checks passed
@furedea
furedea deleted the build/require-guard-clauses branch November 15, 2026 10:37
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.

1 participant