-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[pydoclint
] Deduplicate collected exceptions after traversing function bodies
#12642
Conversation
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we use a BTreeSet
instead, to get this for free?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so, because we're storing ExceptionEntry
objects in the Vec
rather than QualifiedName
s. ExceptionEntry
s have two fields — one is a QualifiedName
and the other is a TextRange
. We want to make sure that no two ExceptionEntry
s in the Vec have the same QualifiedName
, regardless of whether they have the same TextRange
or not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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