[pydoclint] Ignore DOC201 when function name is "__new__"#13300
[pydoclint] Ignore DOC201 when function name is "__new__"#13300AlexWaygood merged 1 commit intoastral-sh:mainfrom
pydoclint] Ignore DOC201 when function name is "__new__"#13300Conversation
|
There was a problem hiding this comment.
It is actually possible for __new__ methods to not return an instance of the class (e.g. https://github.com/python/cpython/blob/962304a54ca79da0838cf46dd4fb744045167cdd/Lib/pathlib/_local.py#L521-L524). But I agree that that's something of a rare edge case. We could in theory do some static analysis to figure out if __new__ returns an instance of the current class or not, but I think it's probably not worth it with our current type inference capabilities. So this LGTM.
I do also agree that we could probably extend it to some other dunders as well -- probably all of these?
ruff/crates/ruff_python_stdlib/src/typing.rs
Lines 355 to 370 in 7c872e6
(These can be done as a followup, so I merged this for now :-) |
Summary
Resolves #13079.
Do not enforce the documentation of
returnin a__new__function. Arguably this could apply to some other dunder methods.Test Plan
Added fixture.