[pydoclint] Deduplicate collected exceptions after traversing function bodies#12642
[pydoclint] Deduplicate collected exceptions after traversing function bodies#12642AlexWaygood merged 1 commit intomainfrom
pydoclint] Deduplicate collected exceptions after traversing function bodies#12642Conversation
57d7cbc to
1b4529b
Compare
|
| code | total | + violation | - violation | + fix | - fix |
|---|---|---|---|---|---|
| DOC501 | 647 | 3 | 644 | 0 | 0 |
| }); | ||
| raised_exceptions.dedup_by(|left, right| { | ||
| left.qualified_name.segments() == right.qualified_name.segments() | ||
| }); |
There was a problem hiding this comment.
Could we use a BTreeSet instead, to get this for free?
There was a problem hiding this comment.
I don't think so, because we're storing ExceptionEntry objects in the Vec rather than QualifiedNames. ExceptionEntrys have two fields — one is a QualifiedName and the other is a TextRange. We want to make sure that no two ExceptionEntrys in the Vec have the same QualifiedName, regardless of whether they have the same TextRange or not
There was a problem hiding this comment.
It is possible to do this by implementing Hash for ExceptionEntry manually, and omitting TextRange. But probably not worth it, can create confusion.
1b4529b to
0907b72
Compare
Summary
I noticed when looking through the ecosystem report for #12639 that a function like this will be flagged twice for not stating in its docstring that it raises
TypeError. We probably only need to emit one DOC501 violation for such a function:Test Plan
cargo test -p ruff_linter