-
- Notifications
You must be signed in to change notification settings - Fork 19.4k
require Return section only if return is not None nor commentary #25008
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
Merged
TomAugspurger merged 45 commits into pandas-dev:master from dluiscosta:check-return-necessity Mar 11, 2019
Merged
Changes from 1 commit
Commits
Show all changes
45 commits Select commit Hold shift + click to select a range
575abc4 Return section only required if at least one return is not None nor c…
4b6406f fixed PEP8 issues
b204f11 added another "return" on test
0a76a3a now respects summary in a single line
d35ec84 only look for return commands after docstring
e7d9bed Added comments to regex that finds non-bare return commands
2cdd367 added space around bitwise or operator
0e25d93 Replaced [ \t\f\v] for \s on regex.
d5d9800 Added test with valued return after bare returns
073a6b6 method_source now returns source without docstring
0143b7c Updated to search string without whitespaces.
76188dd Simplified regex.
2051ea6 Created clean_method_source property without comments or docstring.
ff17a79 Updated clean_method_source to remove comments.
bafc25d Updated clean_method_source, remove duplicate and trailing whitespaces.
172115a Included test coverage for variable with "return" on the name.
d5e0de8 Updated regex with word bondaries.
0e61d2c Shortened line.
4c89beb Merged return_not_documented tests into simplified version.
b04110a Removed random elements from tests.
dluiscosta 4b01092 Switched to AST approach.
dluiscosta 0928ba6 Removed clean_method_source property.
dluiscosta 57fdb1e Updated does_nothing test not to leave variable unused.
dluiscosta 00d5fdb Reestructured and minimized tests.
dluiscosta 0a0c05e Encapsulated search for returns on method_returns property.
dluiscosta 6ab2534 Updated method_returns property to ignore nested functions.
dluiscosta 504ea10 Updated ast.parse call.
dluiscosta 17737d1 Fixed linting errors.
dluiscosta fe23351 Updated method_source to remove common indentation from lines.
dluiscosta 783eb39 Corrected method_source.
dluiscosta 2c41bd7 Reverted ast.parse call.
dluiscosta 6e53215 Updated method_returns to respect empty method_sources.
dluiscosta 2c60e4d Fixed linting error.
dluiscosta 11b827b Merge branch 'master' into check-return-necessity
dluiscosta 3e93cbe Updated method_source property, removing from try block what can't fail.
dluiscosta 1660060 Refactored method_returns to method_returns_something.
dluiscosta be6c906 Added docstring to method_returns_something.
dluiscosta 0b361de Improved method_returns_something readability.
dluiscosta 2ebfa33 Corrected method_returns_something property docstring.
dluiscosta 65b0f56 Removed unecessary print from test no_returns.
datapythonista bbf39d0 Simplified return_not_documented test.
dluiscosta 2c66c89 Removed mistakenly added whitespaces.
dluiscosta d99edb3 Merge branch 'master' into check-return-necessity
dluiscosta 07a4b01 Added dedent.
dluiscosta 4d6ec7e Merge branch 'master' into check-return-necessity
dluiscosta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Refactored method_returns to method_returns_something.
- Loading branch information
commit 1660060a1cda3969ac4cf64dafedcdf4e8e6d65d
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
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.
As opposing to using
ast.walk()to iterate over all the nodes on the method's AST, here I'm recursively walking the tree myself.The reason for that is to respect cases like the following:
In this case, there is a inner function which returns a string, but the function being evaluated itself always return None, thus shouldn't have a Returns section on the docstring.
If I read all the nodes indiscriminately, as happens with
ast.walk(), I can't distinguish returns inside nested functions from returns on the function actually being evaluated. If I search trough it myself, though, I can prune the recursion when I reach a (nested) function node, thus ignoring it's entire subtree and possible return nodes in it.