Title: Don't return with operand when conceptually void by EliahKagan · Pull Request #1755 · gitpython-developers/GitPython · GitHub
Open Graph Title: Don't return with operand when conceptually void by EliahKagan · Pull Request #1755 · gitpython-developers/GitPython
X Title: Don't return with operand when conceptually void by EliahKagan · Pull Request #1755 · gitpython-developers/GitPython
Description: This changes return None to return where it appears in functions that are "conceptually void," i.e. cases where a function always returns None, its purpose is never to provide a return value to the caller, and it would be a bug (or at least confusing style) to use the return value or have the call as a subexpression. This is already the prevailing style, so this is a consistency improvement, as well as improving clarity by avoiding giving the impression that "None" is significant in those cases. Of course, functions that sometimes return values other than None do not have return None replaced with a bare return statement. Those are left alone (when they return None, it means something). For the most part this is straightforward, but: The handle_stderr local function in IndexFile.checkout is also slightly further refactored to better express what the early return is doing. Because it is a local function, the diff in the "Files Changed" tab of this pull request makes it look like it is in the checkout method, where such a change would not be correct. Instead, that is the enclosing scope, and it is in a nested function where the change does make sense. The None operand is removed as usual in GitConfigParser.read, even though a superclass has a same-named method with a return type that is not None. Usually when this happens, the superclass method returns something like Optional[Something], and it is a case of return-type covariance, in which case the None operands should still be written. Here, however, the overriding method does not intend to be an override: it has an incompatible signature and cannot be called as if it were the superclass method, nor is its return type compatible. The None operand is retained in the code at the very end of git.cmd.handle_process_output, even though the return type is annotated as None, because the function also returns the expression finalizer(process). The argument finalizer is itself annotated to return None, but it looks like the intent may be to play along with the strange case that finalizer returns a non-None value, and forward it: GitPython/git/cmd.py Lines 207 to 210 in b8ee9be if finalizer: return finalizer(process) else: return None So changing return None to return doesn't make sense there. But depending on intent, maybe it should be just: if finalizer: finalizer(process) I noticed after #1754, which made changes to Git.AutoInterrupt._terminate, was approved, that I had should have fixed how it used return in some places and return None in others. So I looked for return None that should be return throughout the project to see what else to fix along with it, resulting in this PR.
Open Graph Description: This changes return None to return where it appears in functions that are "conceptually void," i.e. cases where a function always returns None, its purpose is never to provide a return va...
X Description: This changes return None to return where it appears in functions that are "conceptually void," i.e. cases where a function always returns None, its purpose is never to provide a r...
Opengraph URL: https://github.com/gitpython-developers/GitPython/pull/1755
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/checks(.:format) |
| route-controller | pull_requests |
| route-action | checks |
| fetch-nonce | v2:d75b9cee-6c51-b16f-298d-08ab3739f25b |
| current-catalog-service-hash | 87dc3bc62d9b466312751bfd5f889726f4f1337bdff4e8be7da7c93d6c00a25a |
| request-id | C49E:27A700:C4C384:1183651:6969087D |
| html-safe-nonce | 50942ce085a46fda61a3d38779bd51465f49220fc05361e293da93cd3b942cbc |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNDlFOjI3QTcwMDpDNEMzODQ6MTE4MzY1MTo2OTY5MDg3RCIsInZpc2l0b3JfaWQiOiIyNDA4MTA5NjEzOTc4ODE0NTg5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 2d3a8944c373860c428c80f39ea193f509ea318c21e30dff88e7cf6b26f6b36b |
| hovercard-subject-tag | pull_request:1627004042 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,checks,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/gitpython-developers/GitPython/pull/1755/checks |
| twitter:image | https://avatars.githubusercontent.com/u/1771172?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/1771172?s=400&v=4 |
| og:image:alt | This changes return None to return where it appears in functions that are "conceptually void," i.e. cases where a function always returns None, its purpose is never to provide a return va... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | e6156bd4ef9f2dc8dadf4c49a8f7ed8532186388cef72eda3ccb9f0ab3b8cfca |
| turbo-cache-control | no-preview |
| go-import | github.com/gitpython-developers/GitPython git https://github.com/gitpython-developers/GitPython.git |
| octolytics-dimension-user_id | 503709 |
| octolytics-dimension-user_login | gitpython-developers |
| octolytics-dimension-repository_id | 1126087 |
| octolytics-dimension-repository_nwo | gitpython-developers/GitPython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1126087 |
| octolytics-dimension-repository_network_root_nwo | gitpython-developers/GitPython |
| turbo-body-classes | logged-out env-production page-responsive full-width full-width-p-0 |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | ee2210c3e58153aae53400c942f8a7b4bbb43ec4 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width