Skip to content

Respect Ruff rule code hierarchy #1526

@nathanjmcdougall

Description

@nathanjmcdougall

If Ruff selection contains "ALL" then we're already selecting all rules! There's not need to explicitly select another rule, it just gets "absorbed" into this "wildcard" style rule.

Similarly, if we want to select a specific rule code like TC001 then if there's already the rule code group like TC then there's no point adding it - we shouldn't.

It also goes the other way. We should replace a less general rule with a more general one. If we want to select TC and there's already TC001 then we should replace TC001 with TC.

All these principles also apply to ignores! And per-file ignores! Any time there's a list of ruff rules.

We should probably keep the current level of abstraction which manages the raw rule lists, but basically move that into helper methods, and so we can add some smart logic on top that manages the hierarchy between rule codes.

It is safe to assume that all rule codes follow this pattern - not just Ruff.

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions