File tree 2 files changed +14
-1
lines changed
resources/test/fixtures/pydoclint
src/rules/pydoclint/rules
2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -207,3 +207,10 @@ def foo(s: str) -> str | None:
207
207
s (str): A string.
208
208
"""
209
209
return None
210
+
211
+
212
+ class Spam :
213
+ # OK
214
+ def __new__ (cls ) -> 'Spam' :
215
+ """New!!"""
216
+ return cls ()
Original file line number Diff line number Diff line change @@ -741,6 +741,10 @@ fn returns_documented(
741
741
|| ( matches ! ( convention, Some ( Convention :: Google ) ) && starts_with_returns ( docstring) )
742
742
}
743
743
744
+ fn should_document_returns ( function_def : & ast:: StmtFunctionDef ) -> bool {
745
+ !matches ! ( function_def. name. as_str( ) , "__new__" )
746
+ }
747
+
744
748
fn starts_with_yields ( docstring : & Docstring ) -> bool {
745
749
if let Some ( first_word) = docstring. body ( ) . as_str ( ) . split ( ' ' ) . next ( ) {
746
750
return matches ! ( first_word, "Yield" | "Yields" ) ;
@@ -868,7 +872,9 @@ pub(crate) fn check_docstring(
868
872
869
873
// DOC201
870
874
if checker. enabled ( Rule :: DocstringMissingReturns ) {
871
- if !returns_documented ( docstring, & docstring_sections, convention) {
875
+ if should_document_returns ( function_def)
876
+ && !returns_documented ( docstring, & docstring_sections, convention)
877
+ {
872
878
let extra_property_decorators = checker. settings . pydocstyle . property_decorators ( ) ;
873
879
if !definition. is_property ( extra_property_decorators, semantic) {
874
880
if let Some ( body_return) = body_entries. returns . first ( ) {
You can’t perform that action at this time.
0 commit comments