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: redirect.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:1a0a7411-245f-6b4e-c4c2-b951d9d3bb0f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D196:20D38B:6F6B82:9D73FB:696A4D13 |
| html-safe-nonce | c12be927aa16c793e1f6dcc68154b5e4d1871b5b5495b20b932a53cc8bba889d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMTk2OjIwRDM4Qjo2RjZCODI6OUQ3M0ZCOjY5NkE0RDEzIiwidmlzaXRvcl9pZCI6IjE3NTUzMDgxOTMxMDU5ODg4ODMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 012733d39da2b4a6a9f68892671c7a50d23fcede4cb7600703a9bf82a8a219a9 |
| 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 | 3f871c8e07f0ae1886fa8dac284166d28b09ad5bada6476fc10b674e489788ef |
| 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 | 63c426b30d262aba269ef14c40e3c817b384cd61 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width