astral-sh / ruff

An extremely fast Python linter and code formatter, written in Rust.
https://docs.astral.sh/ruff
MIT License
28.6k stars 926 forks source link

Add default linter rules #11415

Open AndreuCodina opened 1 month ago

AndreuCodina commented 1 month ago

In my company we have lots of microservices and nanoservices, and a Python project prototype I maintain to guide how Python projects must be developed and updated. It's a common complaint not to have default rules in our pyproject.toml files, and instead have "magic letters" just because "I chose them". My job is to ensure data engineers develop software as we do in .NET, i.e. with types.

I want to propose a group of default linter rules, and choose them with groups (letters), instead of choosing a subset.

pyproject.toml

[tool.ruff.lint]
select = ["F", "E", "W", "N", "I", "ANN"]
ignore = ["E501", "ANN101", "ANN102", "ANN401"]

Reasoning of select:

Reasoning of ignore:

Besides, I always use this configuration:

[tool.pyright]
typeCheckingMode = "strict"

[tool.ruff]
src = ["src", "tests"]
extend-include = ["*.ipynb"]
zanieb commented 1 month ago

Hi!

We're going to recategorize all of the rules (roughly discussed in https://github.com/astral-sh/ruff/issues/1774) and define new defaults eventually. We're actively working on this, but I'm not sure when we'll be done because it's a big project and we want to get it right.

zanieb commented 1 month ago

Similarly, this request fits into https://github.com/astral-sh/ruff/issues/1773 which is a part of that effort.

dhruvmanila commented 1 month ago

@zanieb Do you think this can be merged into either of the linked issue?

zanieb commented 1 month ago

I'm okay with keeping it open for now unless there's a duplicate issue regarding defaults.

We should add a dedicated tracking issue for the full re-categorization work eventually.