-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[DOC201
] Permit explicit None
in functions that only return None
#13064
Conversation
871f8ac
to
dfee156
Compare
DOC201
] Permit explicit None early returnsDOC201
] Permit explicit None in functions that only return None
DOC201
] Permit explicit None in functions that only return NoneDOC201
] Permit explicit None
in functions that only return None
|
code | total | + violation | - violation | + fix | - fix |
---|---|---|---|---|---|
DOC201 | 67 | 0 | 67 | 0 | 0 |
There's some situations in the ecosystem check here where the diagnostic is going away and it looks like a false negative is introduced, such as https://github.com/apache/airflow/blob/6c878866dedc182c55e18e490bff3f3a9e9c5747/airflow/providers/airbyte/operators/airbyte.py#L126. The reason there for the error going away is that the function is typed as always returning |
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.
Thanks!
CodSpeed Performance ReportMerging #13064 will degrade performances by 9.33%Comparing Summary
Benchmarks breakdown
|
Looks spurious; it's been very unreliable recently sadly |
Summary
No longer reports docstring-missing-returns (DOC201) on explicit returns in functions that only return
None
.For example,
no longer reports DOC201.
Closes #13062
Methodology
When visiting, count the number of
return None
s visited in the body. There are then two scenarios under which the diagnostic is skipped:return None
to the total number of returns (that is to say, all the paths returnNone
), skip the diagnostic.None
, skip the diagnostic.Return annotations
I saw in the ecosystem check that functions that only return
None
but annotated otherwise were now being ignored. For example,would no longer report a diagnostic. I changed this back by always checking the rule if the return annotation is not
None
: if the return annotation is anything other thanNone
, run the diagnostic.I think this is more likely to be the expected behaviour, especially due to the functional overlap between docstrings and type annotations. You could argue that checking against the return type annotation should be all this patch does, but that would make the rule quite unhelpful in untyped contexts. For example,
would still report DOC201.
Test Plan
cargo nextest run