-
- 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
Changes from 1 commit
575abc4 4b6406f b204f11 0a76a3a d35ec84 e7d9bed 2cdd367 0e25d93 d5d9800 073a6b6 0143b7c 76188dd 2051ea6 ff17a79 bafc25d 172115a d5e0de8 0e61d2c 4c89beb b04110a 4b01092 0928ba6 57fdb1e 00d5fdb 0a0c05e 6ab2534 504ea10 17737d1 fe23351 783eb39 2c41bd7 6e53215 2c60e4d 11b827b 3e93cbe 1660060 be6c906 0b361de 2ebfa33 65b0f56 bbf39d0 2c66c89 d99edb3 07a4b01 4d6ec7e File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| | @@ -504,23 +504,26 @@ def method_source(self): | |
| | ||
| @property | ||
| def method_returns(self): | ||
| (tree, ) = ast.parse(self.method_source).body | ||
| | ||
| def gather_returns(node): | ||
| gathered = [node] if isinstance(node, ast.Return) else [] | ||
| for child in ast.iter_child_nodes(node): | ||
| # Ignore nested functions and its subtrees. | ||
| if not isinstance(child, ast.FunctionDef): | ||
| gathered.extend(gather_returns(child)) | ||
| return gathered | ||
| # Walk the tree recursively and gather the return nodes. | ||
| return_values = [r.value for r in gather_returns(tree)] | ||
| | ||
| # Replace NameConstant nodes valued None for None. | ||
| for i, v in enumerate(return_values): | ||
| if isinstance(v, ast.NameConstant) and v.value is None: | ||
| return_values[i] = None | ||
| return return_values | ||
| tree = ast.parse(self.method_source).body | ||
| if tree: | ||
| root = tree[0] | ||
| def gather_returns(node): | ||
| ||
| gathered = [node] if isinstance(node, ast.Return) else [] | ||
| for child in ast.iter_child_nodes(node): | ||
| # Ignore nested functions and its subtrees. | ||
| if not isinstance(child, ast.FunctionDef): | ||
| gathered.extend(gather_returns(child)) | ||
| return gathered | ||
| # Walk the tree recursively and gather the return nodes. | ||
| return_values = [r.value for r in gather_returns(root)] | ||
| ||
| | ||
| # Replace NameConstant nodes valued None for None. | ||
| for i, v in enumerate(return_values): | ||
| if isinstance(v, ast.NameConstant) and v.value is None: | ||
| return_values[i] = None | ||
| return return_values | ||
| else: | ||
| return [] | ||
| | ||
| @property | ||
| def first_line_ends_in_dot(self): | ||
| | ||
Uh oh!
There was an error while loading. Please reload this page.