René's URL Explorer Experiment


Title: The public interface of git.exc is ambiguous · Issue #1718 · gitpython-developers/GitPython · GitHub

Open Graph Title: The public interface of git.exc is ambiguous · Issue #1718 · gitpython-developers/GitPython

X Title: The public interface of git.exc is ambiguous · Issue #1718 · gitpython-developers/GitPython

Description: I believe the intent of git.exc is twofold: To publish the exceptions it defines, which it unambiguously does. To republish exceptions defined in gitdb.exc, which it... doesn't? The problem is that the conceptually public names in a modu...

Open Graph Description: I believe the intent of git.exc is twofold: To publish the exceptions it defines, which it unambiguously does. To republish exceptions defined in gitdb.exc, which it... doesn't? The problem is that...

X Description: I believe the intent of git.exc is twofold: To publish the exceptions it defines, which it unambiguously does. To republish exceptions defined in gitdb.exc, which it... doesn't? The problem is ...

Opengraph URL: https://github.com/gitpython-developers/GitPython/issues/1718

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"The public interface of git.exc is ambiguous","articleBody":"I believe the intent of `git.exc` is twofold:\r\n\r\n- To publish the exceptions it defines, which it unambiguously does.\r\n- To republish exceptions defined in `gitdb.exc`, which it... *doesn't?*\r\n\r\nThe problem is that the conceptually public names in a module are (basically) those listed in `__all__` when `__all__` is present, and since an original and continuing use of `__all__` is to control what names a `*` import binds, it might seem like whatever a `*` import binds is considered conceptually public even without `__all__`... but that is not the case.\r\n\r\nInstead, in the absence of `__all__`, names that both do not start with an `_` and also *were not introduced merely by themselves being imported* are the conceptually public names. As [the \"Public and internal interfaces\" section of PEP-8](https://pep8.org/#public-and-internal-interfaces) says:\r\n\r\n\u003e Imported names should always be considered an implementation detail. Other modules must not rely on indirect access to such imported names unless they are an explicitly documented part of the containing module’s API\u003cem\u003e[...]\u003c/em\u003e\r\n\r\nTo make such a name public, it can be included in `__all__`, but `git.exc` currently does not define `__all__`. Does it otherwise document those names as public? Well...\r\n\r\nhttps://github.com/gitpython-developers/GitPython/blob/44102f30eaadcd122899f5f801f28b83bd9a5111/git/exc.py#L6\r\n\r\nThis is why I say the situation is ambiguous--this might be interpreted to mean that the names are public, in that they are the names of exceptions that are thrown throughout GitPython and would not otherwise be public in GitPython. But really this is a stretch, and rather than saying the situation is ambiguous, it might be more reasonable to say that they are definitely not public.\r\n\r\nBut I am pretty sure they are intended to be public. So they should be documented as such. The best way to do this is by defining `git.exc.__all__` and listing them there.\r\n\r\nThere then becomes the question of whether anything else that is currently imported by `from git.exc import *` belongs in `__all__`. I believe the answer is no. It's not reasonable for code outside `git.exc` to rely on those being part of `git.exc` (because they are present only due to imports, so they are nonpublic per the above-quoted rule, and the documentation of `git.exc` does not reference them even obliquely). It is especially unreasonable for code outside the `git.exc` module to rely on receiving them from a `*` import.\r\n\r\nHowever, the top-level `__init__.py` does just that. *When* it began to do it depends on one's perspective. For some time, it has been including those names (such as `safe_decode` from `git.util`) in `git.__all__` because of the way `git.__all__` was dynamically generated with a comprehension. In #1659, the comprehension was removed and replaced with a listing of everything that was found to be in `__all__`.\r\n\r\nBecause `git.__all__` did, and does, exist, and it included those names, it should continue to include them for backward compatibility, even in the case of some of them from `typing` that hopefully no one is importing from the `git` module. However, I think no similar reasoning applies to `git.exc` itself, since `git.exc.__all__` has not existed. This is to say that I think it is always a bug to rely on picking up nonpublic names from `*` imports, including in `git/__init__.py`, which is currently doing that.\r\n\r\nTo keep `from git import *` working, as well as to keep `git.__all__` a correct statement of names guaranteed accessible as attributes of `git`, when fixing this in `git.exc` it will also be necessary to modify the code of `git/__init__.py` to get these names from the modules that really provide them publicly. That should be no problem, though, and I'd say it would be an improvement even by itself.\r\n\r\nI believe `git.exc` is the clearest place in GitPython where this kind of problem exists, but every attempt to suppress an unused import lint rule is a strong hint of a similar bug, so I'm pretty sure this is far from the only case. However, I'm opening an issue about this specifically because recent changes (in #1659) combine with it to create a situation where the bug could become entrenched if not addressed fairly soon. I say this because although `git/__init__.py` has, for quite some time, being wrongly relying on those names being present, in that it has been effectively guaranteeing their presence for future patch versions by including them in `__all__` as it would be inspected by users, it is only now that this dependence can be easily discerned, and thus perhaps further relied on, by reading the code.","author":{"url":"https://github.com/EliahKagan","@type":"Person","name":"EliahKagan"},"datePublished":"2023-10-20T07:34:36.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/1718/GitPython/issues/1718"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:5e38d84a-2ad7-dee6-348a-6f5b0d90be63
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idB7B8:211260:535DE2:7424CB:6968CB3E
html-safe-nonce5c017f9a86ed1a74676b2e25cec85081dc252c2d96c44c1999a2a74cee87c334
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCN0I4OjIxMTI2MDo1MzVERTI6NzQyNENCOjY5NjhDQjNFIiwidmlzaXRvcl9pZCI6IjM2NTk5Mzk0MTM2MzkwODg5NTgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac0ddab5f13679aa5c89663d131af8b02c8935eaff33439c518c4ff2acc2fd98c9
hovercard-subject-tagissue:1953712981
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/gitpython-developers/GitPython/1718/issue_layout
twitter:imagehttps://opengraph.githubassets.com/21766b18e6c2196e435dd01727497d80a836ef840d5432c9495c46a6599807f3/gitpython-developers/GitPython/issues/1718
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/21766b18e6c2196e435dd01727497d80a836ef840d5432c9495c46a6599807f3/gitpython-developers/GitPython/issues/1718
og:image:altI believe the intent of git.exc is twofold: To publish the exceptions it defines, which it unambiguously does. To republish exceptions defined in gitdb.exc, which it... doesn't? The problem is that...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameEliahKagan
hostnamegithub.com
expected-hostnamegithub.com
Noneaf2d7af0cc84117fa10bf36808605ef68a335c9d8a804b9cdac55f8d77230b00
turbo-cache-controlno-preview
go-importgithub.com/gitpython-developers/GitPython git https://github.com/gitpython-developers/GitPython.git
octolytics-dimension-user_id503709
octolytics-dimension-user_logingitpython-developers
octolytics-dimension-repository_id1126087
octolytics-dimension-repository_nwogitpython-developers/GitPython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id1126087
octolytics-dimension-repository_network_root_nwogitpython-developers/GitPython
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasecc844ab6ee0198cc2e2c142dcb8a5c2a61d48743
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/gitpython-developers/GitPython/issues/1718#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgitpython-developers%2FGitPython%2Fissues%2F1718
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgitpython-developers%2FGitPython%2Fissues%2F1718
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=gitpython-developers%2FGitPython
Reloadhttps://github.com/gitpython-developers/GitPython/issues/1718
Reloadhttps://github.com/gitpython-developers/GitPython/issues/1718
Reloadhttps://github.com/gitpython-developers/GitPython/issues/1718
gitpython-developers https://github.com/gitpython-developers
GitPythonhttps://github.com/gitpython-developers/GitPython
Please reload this pagehttps://github.com/gitpython-developers/GitPython/issues/1718
Notifications https://github.com/login?return_to=%2Fgitpython-developers%2FGitPython
Fork 964 https://github.com/login?return_to=%2Fgitpython-developers%2FGitPython
Star 5k https://github.com/login?return_to=%2Fgitpython-developers%2FGitPython
Code https://github.com/gitpython-developers/GitPython
Issues 169 https://github.com/gitpython-developers/GitPython/issues
Pull requests 8 https://github.com/gitpython-developers/GitPython/pulls
Discussions https://github.com/gitpython-developers/GitPython/discussions
Actions https://github.com/gitpython-developers/GitPython/actions
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/gitpython-developers/GitPython/security
Please reload this pagehttps://github.com/gitpython-developers/GitPython/issues/1718
Insights https://github.com/gitpython-developers/GitPython/pulse
Code https://github.com/gitpython-developers/GitPython
Issues https://github.com/gitpython-developers/GitPython/issues
Pull requests https://github.com/gitpython-developers/GitPython/pulls
Discussions https://github.com/gitpython-developers/GitPython/discussions
Actions https://github.com/gitpython-developers/GitPython/actions
Security https://github.com/gitpython-developers/GitPython/security
Insights https://github.com/gitpython-developers/GitPython/pulse
New issuehttps://github.com/login?return_to=https://github.com/gitpython-developers/GitPython/issues/1718
New issuehttps://github.com/login?return_to=https://github.com/gitpython-developers/GitPython/issues/1718
#1719https://github.com/gitpython-developers/GitPython/pull/1719
The public interface of git.exc is ambiguoushttps://github.com/gitpython-developers/GitPython/issues/1718#top
#1719https://github.com/gitpython-developers/GitPython/pull/1719
acknowledgedhttps://github.com/gitpython-developers/GitPython/issues?q=state%3Aopen%20label%3A%22acknowledged%22
help wantedhttps://github.com/gitpython-developers/GitPython/issues?q=state%3Aopen%20label%3A%22help%20wanted%22
https://github.com/EliahKagan
https://github.com/EliahKagan
EliahKaganhttps://github.com/EliahKagan
on Oct 20, 2023https://github.com/gitpython-developers/GitPython/issues/1718#issue-1953712981
the "Public and internal interfaces" section of PEP-8https://pep8.org/#public-and-internal-interfaces
GitPython/git/exc.pyhttps://github.com/gitpython-developers/GitPython/blob/44102f30eaadcd122899f5f801f28b83bd9a5111/git/exc.py#L6
44102f3https://github.com/gitpython-developers/GitPython/commit/44102f30eaadcd122899f5f801f28b83bd9a5111
#1659https://github.com/gitpython-developers/GitPython/pull/1659
#1659https://github.com/gitpython-developers/GitPython/pull/1659
acknowledgedhttps://github.com/gitpython-developers/GitPython/issues?q=state%3Aopen%20label%3A%22acknowledged%22
help wantedhttps://github.com/gitpython-developers/GitPython/issues?q=state%3Aopen%20label%3A%22help%20wanted%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.