René's URL Explorer Experiment


Title: typeshed annotations do not permit instantiation of urllib.error.HTTPError · Issue #1377 · python/typeshed · GitHub

Open Graph Title: typeshed annotations do not permit instantiation of urllib.error.HTTPError · Issue #1377 · python/typeshed

X Title: typeshed annotations do not permit instantiation of urllib.error.HTTPError · Issue #1377 · python/typeshed

Description: Currently in typeshed, urllib.error.HTTPError is (accurately) annotated as inheriting both URLError and urllib.response.addinfourl. The addinfourl class inherits addbase, which is annotated as inheriting typing.BinaryIO. This appears to ...

Open Graph Description: Currently in typeshed, urllib.error.HTTPError is (accurately) annotated as inheriting both URLError and urllib.response.addinfourl. The addinfourl class inherits addbase, which is annotated as inhe...

X Description: Currently in typeshed, urllib.error.HTTPError is (accurately) annotated as inheriting both URLError and urllib.response.addinfourl. The addinfourl class inherits addbase, which is annotated as inhe...

Opengraph URL: https://github.com/python/typeshed/issues/1377

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"typeshed annotations do not permit instantiation of urllib.error.HTTPError","articleBody":"Currently in typeshed, [urllib.error.HTTPError is (accurately) annotated](https://github.com/python/typeshed/blob/master/stdlib/3/urllib/error.pyi#L8) as inheriting both `URLError` and `urllib.response.addinfourl`. The `addinfourl` class inherits `addbase`, which [is annotated](https://github.com/python/typeshed/blob/master/stdlib/3/urllib/response.pyi#L6) as inheriting [typing.BinaryIO](https://github.com/python/typing/blob/master/src/typing.py#L2312). This appears to be an attempt to deal with the fact that `addbase` [actually inherits](https://github.com/python/cpython/blob/master/Lib/urllib/response.py#L14) the (private) `tempfile._TemporaryFileWrapper`, which is supposed to wrap a \"file-like object\", and [proxies all attribute access to the wrapped object](https://github.com/python/cpython/blob/master/Lib/tempfile.py#L473).\r\n\r\nThis makes some sense: `BinaryIO` is supposed to be the typing \"definition\" of what \"file-like object\" means (at least in binary mode). And this works OK for type-checking code that accesses \"file-like\" methods on an `HTTPError` instance. But it makes it impossible to actually instantiate an `HTTPError` without a spurious mypy error, because the methods of `typing.BinaryIO` (and its parent `typing.IO`) [are all decorated as @abstractmethod](https://github.com/python/typeshed/blob/master/stdlib/3/typing.pyi#L393), and most of them are not overridden by the typeshed annotation of `addbase` or `addinfourl`.\r\n\r\nSo if you type-check this code (which works fine at runtime):\r\n\r\n```\r\nfrom io import StringIO\r\nfrom urllib.error import HTTPError\r\n\r\nhttp_error = HTTPError(\"\", 500, \"message\", dict(), StringIO(''))\r\n```\r\n\r\nmypy gives you:\r\n\r\n```\r\nerror: Cannot instantiate abstract class 'HTTPError' with abstract attributes '__enter__', '__exit__', ... and 'writelines' (16 methods suppressed)\r\n```\r\n\r\nI'm filing an issue rather than going straight to pull request because the correct fix here isn't obvious to me, and I'm hoping someone with more typeshed experience can offer a preferred solution. If so, I'm happy to implement it. The obvious solution seems to be repeating all the method definitions from `typing.BinaryIO` and `typing.IO` in the typeshed annotation for `addbase`, without `@abstractmethod`, but I'm hoping there might be an option that avoids this duplication.","author":{"url":"https://github.com/carljm","@type":"Person","name":"carljm"},"datePublished":"2017-06-01T04:10:58.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/1377/typeshed/issues/1377"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:3a9b1ec5-c428-05ff-6117-8b4de8746564
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idBA56:2CFC95:1945F5B:2251778:6A536337
html-safe-nonce8f9e921cd252cf86aa4feba0f45fa820139920c5f072a5854fd9cde30f89928f
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQTU2OjJDRkM5NToxOTQ1RjVCOjIyNTE3Nzg6NkE1MzYzMzciLCJ2aXNpdG9yX2lkIjoiMTAwOTM0MzczODk4MjY1NDc3NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac6b9016331513259c8f2b41019aa0107359529575770f051dc7f6d7d0f0e424dc
hovercard-subject-tagissue:232760935
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/python/typeshed/1377/issue_layout
twitter:imagehttps://opengraph.githubassets.com/d5bac1049f216af7e318336d3d0573ff8ec32b542a81bbf6a96a73ccc976b0e3/python/typeshed/issues/1377
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/d5bac1049f216af7e318336d3d0573ff8ec32b542a81bbf6a96a73ccc976b0e3/python/typeshed/issues/1377
og:image:altCurrently in typeshed, urllib.error.HTTPError is (accurately) annotated as inheriting both URLError and urllib.response.addinfourl. The addinfourl class inherits addbase, which is annotated as inhe...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamecarljm
hostnamegithub.com
expected-hostnamegithub.com
Noneb9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb
turbo-cache-controlno-preview
go-importgithub.com/python/typeshed git https://github.com/python/typeshed.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id31696383
octolytics-dimension-repository_nwopython/typeshed
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id31696383
octolytics-dimension-repository_network_root_nwopython/typeshed
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
release07a982c1d40157c619b364352b704c3ce66bb332
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/typeshed/issues/1377#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Ftypeshed%2Fissues%2F1377
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
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
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
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/enterprise/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%2Fpython%2Ftypeshed%2Fissues%2F1377
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=python%2Ftypeshed
Reloadhttps://github.com/python/typeshed/issues/1377
Reloadhttps://github.com/python/typeshed/issues/1377
Reloadhttps://github.com/python/typeshed/issues/1377
Please reload this pagehttps://github.com/python/typeshed/issues/1377
python https://github.com/python
typeshedhttps://github.com/python/typeshed
Please reload this pagehttps://github.com/python/typeshed/issues/1377
Notifications https://github.com/login?return_to=%2Fpython%2Ftypeshed
Fork 2.1k https://github.com/login?return_to=%2Fpython%2Ftypeshed
Star 5.1k https://github.com/login?return_to=%2Fpython%2Ftypeshed
Code https://github.com/python/typeshed
Issues 224 https://github.com/python/typeshed/issues
Pull requests 151 https://github.com/python/typeshed/pulls
Actions https://github.com/python/typeshed/actions
Security and quality 0 https://github.com/python/typeshed/security
Insights https://github.com/python/typeshed/pulse
Code https://github.com/python/typeshed
Issues https://github.com/python/typeshed/issues
Pull requests https://github.com/python/typeshed/pulls
Actions https://github.com/python/typeshed/actions
Security and quality https://github.com/python/typeshed/security
Insights https://github.com/python/typeshed/pulse
typeshed annotations do not permit instantiation of urllib.error.HTTPErrorhttps://github.com/python/typeshed/issues/1377#top
https://github.com/carljm
carljmhttps://github.com/carljm
on Jun 1, 2017https://github.com/python/typeshed/issues/1377#issue-232760935
urllib.error.HTTPError is (accurately) annotatedhttps://github.com/python/typeshed/blob/master/stdlib/3/urllib/error.pyi#L8
is annotatedhttps://github.com/python/typeshed/blob/master/stdlib/3/urllib/response.pyi#L6
typing.BinaryIOhttps://github.com/python/typing/blob/master/src/typing.py#L2312
actually inheritshttps://github.com/python/cpython/blob/master/Lib/urllib/response.py#L14
proxies all attribute access to the wrapped objecthttps://github.com/python/cpython/blob/master/Lib/tempfile.py#L473
are all decorated as @abstractmethodhttps://github.com/python/typeshed/blob/master/stdlib/3/typing.pyi#L393
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.