Title: mypy is confused by property aliases · Issue #1934 · gitpython-developers/GitPython · GitHub
Open Graph Title: mypy is confused by property aliases · Issue #1934 · gitpython-developers/GitPython
X Title: mypy is confused by property aliases · Issue #1934 · gitpython-developers/GitPython
Description: Thank you very much for this very useful python package. Unfortunately mypy is very confused by property aliases such as @property def references(self) -> "IterableList[Reference]": """A list of :class:`~git.refs.reference.Reference` obj...
Open Graph Description: Thank you very much for this very useful python package. Unfortunately mypy is very confused by property aliases such as @property def references(self) -> "IterableList[Reference]": """A list of :c...
X Description: Thank you very much for this very useful python package. Unfortunately mypy is very confused by property aliases such as @property def references(self) -> "IterableList[Reference]": &q...
Opengraph URL: https://github.com/gitpython-developers/GitPython/issues/1934
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"mypy is confused by property aliases","articleBody":"Thank you very much for this very useful python package. Unfortunately mypy is very confused by property aliases such as \r\n\r\n```python\r\n @property\r\n def references(self) -\u003e \"IterableList[Reference]\":\r\n \"\"\"A list of :class:`~git.refs.reference.Reference` objects representing tags,\r\n heads and remote references.\r\n\r\n :return:\r\n ``git.IterableList(Reference, ...)``\r\n \"\"\"\r\n return Reference.list_items(self)\r\n\r\n # Alias for references.\r\n refs = references\r\n```\r\n\r\nthat can be found in [`git/repo/base.py`](https://github.com/gitpython-developers/GitPython/blob/4c21e514cd9b5acdc34891fc4b52e9b599810b3e/git/repo/base.py#L405C1-L416C22) or the analogous alias `branches` for `heads`. See https://github.com/python/mypy/issues/6700\r\n\r\nYou can reproduce the issue with the following `test.py`:\r\n```python\r\nfrom git.repo import Repo\r\n\r\nrepo = Repo()\r\nfor branch in repo.branches:\r\n print(branch)\r\n```\r\nabout which `mypy` says:\r\n```\r\ntest.py:4: error: \"Callable[[], IterableList[Head]]\" has no attribute \"__iter__\" (not iterable) [attr-defined]\r\nFound 1 error in 1 file (checked 1 source file)\r\n```\r\n\r\nI am not aware of any fix that would not uglify the code here, and that mypy issue doesn’t seem likely to see improvement in the near future. This is sad, but doing all the work to add type annotations and still having users facing incomprehensible error messages in perfectly legitimate code is also sad. \r\n\r\nCould you please tell me whether you would welcome a PR “fixing” this?","author":{"url":"https://github.com/PatrickMassot","@type":"Person","name":"PatrickMassot"},"datePublished":"2024-06-24T13:38:25.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/1934/GitPython/issues/1934"}
| 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:04b761f0-ad0e-7aa8-9972-c7db6be3c9a9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D850:3CD341:2E1B38:3DC96E:6968719A |
| html-safe-nonce | f86830729389640177b1ec4fea29796c4d8dd11b423f68246a80f7877c92713e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEODUwOjNDRDM0MToyRTFCMzg6M0RDOTZFOjY5Njg3MTlBIiwidmlzaXRvcl9pZCI6IjI0OTE4ODQzMDgyOTY5MjE0OTgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 19b21d76d00c0a816ee51831c0743967cc0bd8de2c423494869a399d48eeb427 |
| hovercard-subject-tag | issue:2370283658 |
| 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/1934/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ac5ec72c8880eac3d15b2d431cf89a7d79d63d6b5bfacb82734cb9599ce0d6d9/gitpython-developers/GitPython/issues/1934 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ac5ec72c8880eac3d15b2d431cf89a7d79d63d6b5bfacb82734cb9599ce0d6d9/gitpython-developers/GitPython/issues/1934 |
| og:image:alt | Thank you very much for this very useful python package. Unfortunately mypy is very confused by property aliases such as @property def references(self) -> "IterableList[Reference]": """A list of :c... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | PatrickMassot |
| hostname | github.com |
| expected-hostname | github.com |
| None | 50f46dc2d6192249fd8ebf20e76c800f4f2596d4a5f3ab63dd63a754df154f54 |
| 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 | fef287f17234b4529a4b112a3d47fe8551e32ddd |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width