Skip to content

exclude looks at path components beyond "project root" (née does --force-exclude work like it should?) #2034

@akx

Description

@akx

I don't think --force-exclude does what it should; this is especially obvious when using pre-commit-ruff (which is supposed to be used with that flag).

In a repository where there are no excludes, or extend-excludes, running ruff --force-exclude . claims there are no Python files. AFAIU this shouldn't happen since nothing is excluded. This happens with --isolated too.

~/b/ruff-force-exclude-test $ ruff --force-exclude --isolated foo/a.py
warning: No Python files found under the given path(s)
~/b/ruff-force-exclude-test $ ruff --isolated foo/a.py
foo/a.py:1:8: F401 `time` imported but unused
Found 1 error(s).
1 potentially fixable with the --fix option.
~/b/ruff-force-exclude-test $
  • A minimal code snippet that reproduces the bug:
  • The command you invoked (e.g., ruff /path/to/file.py --fix), ideally including the --isolated flag:
    • ruff --force-exclude --isolated foo/a.py (or without --isolated)
  • The current Ruff settings (any relevant sections from your pyproject.toml):
    • [tool.ruff]
      target-version = "py37"
      select = ["F401"]
  • The current Ruff version (ruff --version):
    • ruff 0.0.227 (versions before 0.0.204 don't show the warning, but they also don't do anything).

Metadata

Metadata

Assignees

No one assigned

    Labels

    coreRelated to core functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions