-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove conflicting D203 and D213 pydocstyle rules #2289
Conversation
@not-my-profile - Do you have an opinion on the cleanest way to log a warning when the user has one of these codes in their |
bace3df
to
e7c4fa7
Compare
Firstly I am confused that the PR & commit title says "Deprecate" when it in fact removes those rules? I think deprecation is what you do before removal.^^
I think this would actually be a sensible change.
We could make it non-breaking by using the Rust I think the bigger problem of course is that our default rule set (E & F) doesn't include most of our rules but selecting |
Sorry, yeah, I just want to remove these. Honestly I'd rather just remove them than accommodate them in any form, to avoid confusion. But I'll sleep on it. Maybe I'm missing something. |
So yes I think the big problem we should actually address is that we don't have a "default ruleset" that contains all rules that are generally desirable. I think this could be solved via rule categorization (#1774), by introducing a category "experimental" (like clippy's "nursery") and categorizing all problematic rules as "experimental"/"nursery" and letting users simply select all other categories. |
I agree, but I just want to fix this specific case ASAP since it keeps coming up. And even with categorization, we'd run into the problem posed by these specific, conflicting rules: |
Maybe setting |
The other thing we could do is remove these from |
I don't really see this as a problem ... I'd say: If you enable experimental rules you're on you're own ... you accept the risk that these may lead to a bad user experience. We do not guarantee that experimental rules work well on their own or with any other rules (be they non-experimental or experimental).
Yes I think it would make sense to make prefix selectors & |
But, are D203 and D213 really experimental? |
The exact name of that category is of course subject to bikeshedding^^. Well D203 conflicts with PEP 257 ... so yes I think it should certainly not be part of the default ruff experience. And neither should be conflicting rules. Let's discuss some other examples: I consider the current implementation of both of these rules annoying and don't think they should be part of the default ruff experience. Both comparisons with strings and |
Since I think rule categories should be implemented in conjunction with more thorough rule documentation, and I'd like to implement the many-to-many mapping first, I'll quickly implement a "nursery" classification (inspired by clippy). I think "nursery" is a better term than experimental since it's less judgemental. Edit: opened #2292 |
This is another temporary fix for the problem described in #2289 and #2292. Rather than merely warning, we now disable the incompatible rules (in addition to the warning). I actually think this is quite a reasonable solution, but we can revisit later. I just can't bring myself to ship another release with autofix broken-by-default 😂
We now disable these if incompatible pairs are enabled -- which is fine with me for now. |
These rules both have conflicting variants (
D203
conflicts withD211
, andD213
conflicts withD212
). The most common error I see in Ruff is users hitting an infinite autofix iteration loop due to having pairs of these rules enabled (e.g., Ruff goes back-and-forth, adding and removing a newline between the docstring and theclass
definition, until you hit 100 iterations). We display a warning, but... it's just a bad experience, and it comes up way too often.These are the only two codes that are included in none of the built-in conventions, and it seems like
D203
was actually removed from PEP 257 anyway (at least according to this). I did some extensive searching via GitHub Code Search, and I can only ever find these codes referenced inignore
lists. My guess is that there isn't a single Ruff user that has these enabled, at least not intentionally.Here are some examples of this coming up:
As an alternative, I considered:
convention = "pep257"
by default. This would have the effect of disabling the incompatible rules. But, it's a breaking change, and doesn't seem worth it to me.D
orALL
(but not viaD203
orD213
). That would work, but it adds complexity, and it strikes me as a waste of time.