astral-sh / ruff-pre-commit

A pre-commit hook for Ruff.
Apache License 2.0
802 stars 38 forks source link

add instruction on how to force ruff hooks to honor excluded files #60

Closed sam-hosseini closed 6 months ago

sam-hosseini commented 7 months ago

Hi Charlie and the team! 👋🏼

Absolutely in awe, without exaggeration, of what you've built and how it's simplified the lint-/formatting workflows in Python. I read the original project announcement and I wrote it down in my notes as a source of inspiration for turning a curious reader into a fan in as concise and effective of a way as possible.

Thank you very much 🙌🏼


What's the purpose of the change? What does it do, and why?

The purpose is to prevent ruff pre-commit hooks lint-/formatting files I've already excluded in pyproject.toml.

I thought it's necessary because pre-commit lint-/formatting files I've explicitly ignored is rather confusing. Given, of course, not knowing ruff's default behavior of lint-/formatting files passed in directly regardless of exclude/extend-exclude settings (unless --force-exclude is set).

How was it tested?

More like reproduction steps:

1 file reformatted



---

#### Suggestion
If I may give my 2 cents: I think `ruff` ignoring `exclude`/`extend-exclude` unless `force-exclude` is set is confusing and counter-intuitive. I think many folks, myself included, consider `pyproject.toml` the «source of truth» for their config and expect the tools to honor the `exclude` settings specified there. We can always override those in the cli using `--force-format` (made up flag) or similar flags if we want to bypass the «source of truth».

---

Thanks again 😊