Title: Submodule.__init__ `parent_commit` conversion/validation is implied but not done · Issue #1869 · gitpython-developers/GitPython · GitHub
Open Graph Title: Submodule.__init__ `parent_commit` conversion/validation is implied but not done · Issue #1869 · gitpython-developers/GitPython
X Title: Submodule.__init__ `parent_commit` conversion/validation is implied but not done · Issue #1869 · gitpython-developers/GitPython
Description: The parent_commit parameter of Submodule.__init__ is documented this way: GitPython/git/objects/submodule/base.py Lines 135 to 136 in edb8d26 :param parent_commit: See :meth:`set_parent_commit`. Submodule.__init__ binds this directly to ...
Open Graph Description: The parent_commit parameter of Submodule.__init__ is documented this way: GitPython/git/objects/submodule/base.py Lines 135 to 136 in edb8d26 :param parent_commit: See :meth:`set_parent_commit`. Su...
X Description: The parent_commit parameter of Submodule.__init__ is documented this way: GitPython/git/objects/submodule/base.py Lines 135 to 136 in edb8d26 :param parent_commit: See :meth:`set_parent_commit`. Su...
Opengraph URL: https://github.com/gitpython-developers/GitPython/issues/1869
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Submodule.__init__ `parent_commit` conversion/validation is implied but not done","articleBody":"The `parent_commit` parameter of `Submodule.__init__` is documented this way:\r\n\r\nhttps://github.com/gitpython-developers/GitPython/blob/edb8d26e20d16f72240f7040c353d01a3a1a9740/git/objects/submodule/base.py#L135-L136\r\n\r\n`Submodule.__init__` binds this directly to the private `_parent_commit` attribute:\r\n\r\nhttps://github.com/gitpython-developers/GitPython/blob/edb8d26e20d16f72240f7040c353d01a3a1a9740/git/objects/submodule/base.py#L147\r\n\r\nBut this is at odds with the documented relationship to `Submodule.set_parent_commit`. That method's `commit` parameter corresponds to the `parent_commit` parameter of `Submodule.__init__`, in that its `commit` parameter is used to identify the commit, if any, to set as `_parent_commit`. However, `set_parent_commit` performs both conversion and validation.\r\n\r\nThis is the relevant fragment of `set_parent_commit`'s docstring:\r\n\r\nhttps://github.com/gitpython-developers/GitPython/blob/edb8d26e20d16f72240f7040c353d01a3a1a9740/git/objects/submodule/base.py#L1253-L1255\r\n\r\nWhen `commit` is `None`, it sets `None` to `_parent_commit`. Otherwise, however, `commit` may not already be a `Commit` object, and that is okay, because a commit is looked up from it:\r\n\r\nhttps://github.com/gitpython-developers/GitPython/blob/edb8d26e20d16f72240f7040c353d01a3a1a9740/git/objects/submodule/base.py#L1274\r\n\r\nThat's the conversion. Then validation is performed, with `_parent_commit` ending up set to the commit that `commit` identified only if there is such a suitable commit:\r\n\r\nhttps://github.com/gitpython-developers/GitPython/blob/edb8d26e20d16f72240f7040c353d01a3a1a9740/git/objects/submodule/base.py#L1275-L1289\r\n\r\nThe type annotations do not reveal the intent, as they are among those using `Commit_ish` that need to be updated with the fix for `Commit_ish`, and that I am fixing up in #1859. My immediate motivation for opening this issue is that I'm having trouble figuring out how to annotate them, because due to the inconsistency between the docstring and the implementations, I don't know what is intended to be accepted.\r\n\r\nEither the documentation should be updated, which could be part of #1859, or the code should be fixed to perform any expected validation and conversion and a test case added to check that this is working, which would be best done separately from #1859 (lest its scope expand ever further). I am not sure which. For #1859, it is likely sufficient for me to know what is *intended*, so full progress on this is not needed to finish #1859. It is my hope and also strong guess that this issue is not a blocker for #1859.\r\n\r\nThis should not be confused with #1866, which is about the `parent_commits` parameter of `IndexFile.commit` rather than the `parent_commit` parameter of `Submodule.__init__` (and which, unlike this, really is about annotations).","author":{"url":"https://github.com/EliahKagan","@type":"Person","name":"EliahKagan"},"datePublished":"2024-03-12T20:22:33.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":8},"url":"https://github.com/1869/GitPython/issues/1869"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:fb436eae-96ef-3cc3-fd8c-069020d05f31 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E046:211918:145ABF1:1C818DC:6968F206 |
| html-safe-nonce | 199d9add1b64adfa27484d2e57acc94f83715d5ee299f083cd5541db36cbfd42 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMDQ2OjIxMTkxODoxNDVBQkYxOjFDODE4REM6Njk2OEYyMDYiLCJ2aXNpdG9yX2lkIjoiMzc4NTc1MTQ2NTQzOTA2NDU4MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 3ff4566d71129dccaf99ed41a9cb000d222289fa49a40d0cbdf0d2e04760f22b |
| hovercard-subject-tag | issue:2182605418 |
| github-keyboard-shortcuts | repository,issues,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/_view_fragments/issues/show/gitpython-developers/GitPython/1869/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9b2ab2b4d336f7c3f07f168bf155edf84073530716c55d4e85fe7341d742ffd2/gitpython-developers/GitPython/issues/1869 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9b2ab2b4d336f7c3f07f168bf155edf84073530716c55d4e85fe7341d742ffd2/gitpython-developers/GitPython/issues/1869 |
| og:image:alt | The parent_commit parameter of Submodule.__init__ is documented this way: GitPython/git/objects/submodule/base.py Lines 135 to 136 in edb8d26 :param parent_commit: See :meth:`set_parent_commit`. Su... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | EliahKagan |
| hostname | github.com |
| expected-hostname | github.com |
| None | 51dad138a86b7be4249ddf653c758a9e2621d74f432542c93532a31064797ca5 |
| 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 |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | aba32f111c4c7d50bd0c1ac012cd08cdc17512e0 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width