Skip to content

rtk ruff check appends . when every path is dash-prefixed or contains =, so rtk ruff check a=b.py lints the whole tree #4752

Open

Description

@KuSh

ruff_cmd::run appends . to an implicit or explicit check when every argument after check passes a.starts_with('-') || a.contains('=') (src/cmds/python/ruff_cmd.rs:95). That test reads paths as flags: a file named a=b.py, any path after -- that starts with -, and a file named -- all count as flags, so . is added and ruff lints the working directory alongside the requested file.

Reproduction (ruff 0.16.6, LC_ALL=C, a clean file next to 61 modules with unused imports; develop 5ab6291, same on v1.0.1):

command ruff rtk ruff
check a=b.py All checks passed!, exit 0 Ruff: 123 issues in 62 files, exit 1
check -- a=b.py All checks passed!, exit 0 123 issues, exit 1
check -- -dash.py 1 error (the file's own), exit 1 123 issues in 62 files, exit 1
check -- -- (file named --) All checks passed!, exit 0 123 issues, exit 1

The hook reaches the first row: ruff check a=b.py is rewritten to rtk ruff check a=b.py.

Direction: decide "no path given" from the tokenizer (arg_tokenizer: a free positional, or anything after --, is a path) rather than from the token's spelling. #3968 rewrites this routing and may be the place for it.

Also seen by @Protocol-zero-0 in their review of #4727 (check --isolated -- --statistics, check --isolated -- --).

Activity

  1. rtk-wshm-sync-bot commented on Oct 23, 2026

    @rtk-wshm-sync-bot

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟡 Priority medium
    🎯 Confidence 93%

    Summary

    rtk ruff check misclassifies paths as flags (dash-prefixed, containing '=', or named '--'), causing it to append '.' and lint the whole tree instead of the given file.

    📁 Relevant files
    • src/cmds/python/ruff_cmd.rs

    Suggested Actions

    1. Fix ruff_cmd::run's heuristic at src/cmds/python/ruff_cmd.rs:95 to rely on arg_tokenizer classification, not token sp…
    2. Coordinate with fix(ruff): route flag-first implicit check invocations to check (#3927) #3968 since it rewrites the routing logic and may be the natural home for this fix
    3. Add regression tests for a=b.py, -- -dash.py, and a file literally named --
    4. Cross-check fix(ruff): restore a leading -- before routing #4727's review comments from @Protocol-zero-0 for additional edge cases (--isolated -- --statistics)

    Triaged automatically by wshm · This is an automated analysis, not a human review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions