Title: assert_never raises different exception than documented · Issue #1857 · gitpython-developers/GitPython · GitHub
Open Graph Title: assert_never raises different exception than documented · Issue #1857 · gitpython-developers/GitPython
X Title: assert_never raises different exception than documented · Issue #1857 · gitpython-developers/GitPython
Description: git.types.assert_never is documented to raise AssertionError if raise_error is True and exc is None: GitPython/git/types.py Line 83 in b2c3d8b If raise_error is True, will also raise AssertionError or the Exception passed to exc. But it ...
Open Graph Description: git.types.assert_never is documented to raise AssertionError if raise_error is True and exc is None: GitPython/git/types.py Line 83 in b2c3d8b If raise_error is True, will also raise AssertionError...
X Description: git.types.assert_never is documented to raise AssertionError if raise_error is True and exc is None: GitPython/git/types.py Line 83 in b2c3d8b If raise_error is True, will also raise AssertionError...
Opengraph URL: https://github.com/gitpython-developers/GitPython/issues/1857
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"assert_never raises different exception than documented","articleBody":"`git.types.assert_never` is documented to raise `AssertionError` if `raise_error` is `True` and `exc` is `None`:\r\n\r\nhttps://github.com/gitpython-developers/GitPython/blob/b2c3d8b72301dc4723e83de676fd7086d5c3c381/git/types.py#L83\r\n\r\nBut it actually raises `ValueError` in this situation, its full implementation being:\r\n\r\nhttps://github.com/gitpython-developers/GitPython/blob/b2c3d8b72301dc4723e83de676fd7086d5c3c381/git/types.py#L85-L89\r\n\r\nFor comparison. there is an `assert_never` function in Python's `typing` module since 3.11 (and in `typing_extensions`). This function is similar but only has one parameter--which the first parameter of `git.types.assert_never` corresponds to--and it documents *that* it raises an exception if called at runtime, but does not document the type of exception raised. At least currently in Python 3.12, [it raises `AssertionError`](https://github.com/python/cpython/blob/0a9356ce6ddca117588c95480f0ef1ef33df03cb/Lib/typing.py#L2406).\r\n\r\nThe GitPython function is a public member of `git.types`, and it is used internally in GitPython. I don't know if the docstring should be fixed to describe the existing behavior, or if that behavior should itself be considered the bug here and changed to match the docstring.","author":{"url":"https://github.com/EliahKagan","@type":"Person","name":"EliahKagan"},"datePublished":"2024-03-04T21:16:18.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/1857/GitPython/issues/1857"}
| 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:71e48f9f-964b-1c21-cf0a-2809e88d5708 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E690:4D9DF:2A58676:3B5B2BE:69692DF8 |
| html-safe-nonce | b30a11ad264796026489924b4e4a295fdc64ebce52f87e1ffbde860c8fefb33e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNjkwOjREOURGOjJBNTg2NzY6M0I1QjJCRTo2OTY5MkRGOCIsInZpc2l0b3JfaWQiOiIyMDY1NDA2OTQ1MDAxMDI1MDE2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | a2ab91f68800cd6d70da9ac9c51610fed09825996dfcc45f901109964f1d07e8 |
| hovercard-subject-tag | issue:2167773955 |
| 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/1857/issue_layout |
| twitter:image | https://opengraph.githubassets.com/cc5506f64e8333d665bdbec066d3ba81875122d146e6af614608992cce26f3a1/gitpython-developers/GitPython/issues/1857 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/cc5506f64e8333d665bdbec066d3ba81875122d146e6af614608992cce26f3a1/gitpython-developers/GitPython/issues/1857 |
| og:image:alt | git.types.assert_never is documented to raise AssertionError if raise_error is True and exc is None: GitPython/git/types.py Line 83 in b2c3d8b If raise_error is True, will also raise AssertionError... |
| 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 | 54182691a21263b584d2e600b758e081b0ff1d10ffc0d2eefa51cf754b43b51d |
| 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 | d69ac0477df0f87da03b8b06cebd187012d7a930 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width