René's URL Explorer Experiment


Title: Proposal: inheritance + annotations · Issue #269 · python/typing · GitHub

Open Graph Title: Proposal: inheritance + annotations · Issue #269 · python/typing

X Title: Proposal: inheritance + annotations · Issue #269 · python/typing

Description: After some time annotating non-trivial codebases, I've found something that feels like a nuisance and a bad practice. Essentially, when overriding methods in subclasses, having to re-specify the whole type signatures in subclasses is: ty...

Open Graph Description: After some time annotating non-trivial codebases, I've found something that feels like a nuisance and a bad practice. Essentially, when overriding methods in subclasses, having to re-specify the wh...

X Description: After some time annotating non-trivial codebases, I've found something that feels like a nuisance and a bad practice. Essentially, when overriding methods in subclasses, having to re-specify th...

Opengraph URL: https://github.com/python/typing/issues/269

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Proposal: inheritance + annotations","articleBody":"After some time annotating non-trivial codebases, I've found something that feels like a nuisance and a bad practice. Essentially, when overriding methods in subclasses, having to re-specify the whole type signatures in subclasses is:\n- type consuming (I'm writing/annotating a subclass and have to copy potentially complicated types for a lot of parameters)\n- error prone\n- not a source new information (which is the benefit of annotations)\n- a violation of the DRY principle (if I choose to change the type of an argument in the superclass, I have to edit all the subclasses).\n\nOne cases where this trivially happens is when defining standard python magic methods; I want my `__str__` methods checked, but it feels silly to tell the typechecker every time that \"yes, this method returns a string\". It also happens in more complicated definitions, for example https://github.com/dmoisset/django/blob/typing-requests/django/core/files/uploadhandler.py#L83 and https://github.com/dmoisset/django/blob/typing-requests/django/core/files/uploadhandler.py#L83 vs line 170 of the same file.\n\nCurrently, the PEP says «For a checked function, the default annotation for arguments and for the return type is Any». I'd like to introduce some exception to this rule for methods inheriting an annotated method.\n\nI know that there's a potential problem with this that is when inheriting standard classes (especially but not limited to `object`) which already have annotated clases, may force undesired annotations. My idea  here is to introduce some kind of marker (perhaps a `@typing.inherit_type_hints` decorator?) that can be used at class and method levels and means \"inherit annotations from the parent class unless specifically overriden by this class\".  In this way it's opt-in and also tells both the human reader and the static analyzer where to lookup the annotations. \n\nThe implementation of this decorator could be trivial (another identity decorator, just used as a marker for static analysis tools) , but also could actually copy the `__anotations__` field to make the inherited information also available to runtime tools.\n\nWhat do you think of this?\n","author":{"url":"https://github.com/dmoisset","@type":"Person","name":"dmoisset"},"datePublished":"2016-08-26T15:47:02Z","url":"https://github.com/python/typing/issues/269"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:2b47fb36-a904-630d-c633-af1ad6ceb27d
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idCBC6:2E9DBB:240D03B:3140862:6B0035AA
html-safe-nonce747dbfc13a25f02c026224043d016db72c11b047193769bd00754015fbe45631
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQkM2OjJFOURCQjoyNDBEMDNCOjMxNDA4NjI6NkIwMDM1QUEiLCJ2aXNpdG9yX2lkIjoiMjcwMDc3MDc2ODYxNDA3Nzg2NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac9a27b1c58bd9e706f531d7c51bb40a4b642120b9bf5283ef340751fbb014bba2
hovercard-subject-tagissue:173484121
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/typing/269/issue_layout
twitter:imagehttps://opengraph.githubassets.com/6fcf7ce5398a34dd6d510e7b79b80d0a6f990270edd9d0b8eb6b6d2d36553a5e/python/typing/issues/269
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/6fcf7ce5398a34dd6d510e7b79b80d0a6f990270edd9d0b8eb6b6d2d36553a5e/python/typing/issues/269
og:image:altAfter some time annotating non-trivial codebases, I've found something that feels like a nuisance and a bad practice. Essentially, when overriding methods in subclasses, having to re-specify the wh...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamedmoisset
hostnamegithub.com
expected-hostnamegithub.com
None7d0829bbde9e48b2486cb5dd6d147896eb01d32134627091f818958a935ef3f0
turbo-cache-controlno-preview
go-importgithub.com/python/typing git https://github.com/python/typing.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id24604008
octolytics-dimension-repository_nwopython/typing
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id24604008
octolytics-dimension-repository_network_root_nwopython/typing
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
releasef3f3a43ca095cdea3abbb394112e971f9fdb94fa
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/typing/issues/269#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Ftyping%2Fissues%2F269
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
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
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://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
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Ftyping%2Fissues%2F269
Sign uphttps://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%2Ftyping
Reloadhttps://github.com/python/typing/issues/269
Reloadhttps://github.com/python/typing/issues/269
Reloadhttps://github.com/python/typing/issues/269
pythonhttps://github.com/python
typinghttps://github.com/python/typing
Codehttps://github.com/python/typing
Issues206 (206)https://github.com/python/typing/issues
Pull requests27 (27)https://github.com/python/typing/pulls
Discussionshttps://github.com/python/typing/discussions
Actionshttps://github.com/python/typing/actions
Security and qualityhttps://github.com/python/typing/security
Insightshttps://github.com/python/typing/insights
https://github.com/python/typing
New issuehttps://github.com/login?return_to=https://github.com/python/typing/issues/269
New issuehttps://github.com/login?return_to=https://github.com/python/typing/issues/269
Proposal: inheritance + annotationshttps://github.com/python/typing/issues/269#top
topic: featureDiscussions about new features for Python's type annotationshttps://github.com/python/typing/issues?q=state%3Aopen%20label%3A%22topic%3A%20feature%22
https://github.com/dmoisset
dmoissethttps://github.com/dmoisset
on Aug 26, 2016https://github.com/python/typing/issues/269#issue-173484121
https://github.com/dmoisset/django/blob/typing-requests/django/core/files/uploadhandler.py#L83https://github.com/dmoisset/django/blob/typing-requests/django/core/files/uploadhandler.py#L83
https://github.com/dmoisset/django/blob/typing-requests/django/core/files/uploadhandler.py#L83https://github.com/dmoisset/django/blob/typing-requests/django/core/files/uploadhandler.py#L83
https://github.com/gvanrossum
gvanrossumhttps://github.com/gvanrossum
on Aug 26, 2016https://github.com/python/typing/issues/269#issuecomment-242788880
gvanrossumhttps://github.com/gvanrossum
enhancementhttps://github.com/python/typing/issues?q=state%3Aopen%20label%3A%22enhancement%22
on Aug 26, 2016https://github.com/python/typing/issues/269#event-769165540
https://github.com/JukkaL
JukkaLhttps://github.com/JukkaL
on Aug 26, 2016https://github.com/python/typing/issues/269#issuecomment-242804955
https://github.com/dmoisset
dmoissethttps://github.com/dmoisset
on Aug 31, 2016https://github.com/python/typing/issues/269#issuecomment-243746411
@gvanrossumhttps://github.com/gvanrossum
@JukkaLhttps://github.com/JukkaL
https://github.com/JukkaL
JukkaLhttps://github.com/JukkaL
on Aug 31, 2016https://github.com/python/typing/issues/269#issuecomment-243765549
https://github.com/dmoisset
dmoissethttps://github.com/dmoisset
on Sep 1, 2016https://github.com/python/typing/issues/269#issuecomment-244154661
@JukkaLhttps://github.com/JukkaL
PEP-526https://peps.python.org/526
https://github.com/gvanrossum
gvanrossumhttps://github.com/gvanrossum
on Sep 1, 2016https://github.com/python/typing/issues/269#issuecomment-244176614
https://github.com/refi64
refi64https://github.com/refi64
on Sep 1, 2016https://github.com/python/typing/issues/269#issuecomment-244180694
https://github.com/dmoisset
dmoissethttps://github.com/dmoisset
on Sep 1, 2016https://github.com/python/typing/issues/269#issuecomment-244238949
https://docs.microsoft.com/en-us/dotnet/articles/fsharp/language-reference/members/methodshttps://docs.microsoft.com/en-us/dotnet/articles/fsharp/language-reference/members/methods
@JukkaLhttps://github.com/JukkaL
https://github.com/dmoisset
dmoissethttps://github.com/dmoisset
on Sep 2, 2016https://github.com/python/typing/issues/269#issuecomment-244379713
https://www.typescriptlang.org/docs/handbook/classes.htmlhttps://www.typescriptlang.org/docs/handbook/classes.html
https://github.com/JukkaL
JukkaLhttps://github.com/JukkaL
on Sep 2, 2016https://github.com/python/typing/issues/269#issuecomment-244406889
https://www.typescriptlang.org/play/https://www.typescriptlang.org/play/
https://github.com/dmoisset
dmoissethttps://github.com/dmoisset
on Sep 2, 2016https://github.com/python/typing/issues/269#issuecomment-244410092
@JukkaLhttps://github.com/JukkaL
https://github.com/sky-code
sky-codehttps://github.com/sky-code
on Nov 24, 2017https://github.com/python/typing/issues/269#issuecomment-346711357
https://github.com/NeilGirdhar
NeilGirdharhttps://github.com/NeilGirdhar
on Mar 13, 2019https://github.com/python/typing/issues/269#issuecomment-472647787
https://github.com/plcplc
plcplchttps://github.com/plcplc
on Dec 7, 2020https://github.com/python/typing/issues/269#issuecomment-739700558
https://github.com/antonagestam
antonagestamhttps://github.com/antonagestam
on Dec 7, 2020https://github.com/python/typing/issues/269#issuecomment-740018428
@plcplchttps://github.com/plcplc
https://github.com/skilkis
skilkishttps://github.com/skilkis
on Jul 29, 2021https://github.com/python/typing/issues/269#issuecomment-889107470
#270https://github.com/python/typing/issues/270
#270https://github.com/python/typing/issues/270
#270 (comment)https://github.com/python/typing/issues/270#issuecomment-563044037
@rmorsheahttps://github.com/rmorshea
PEP-612https://www.python.org/dev/peps/pep-0612/
https://github.com/srittau
srittauhttps://github.com/srittau
on Nov 4, 2021https://github.com/python/typing/issues/269#issuecomment-960615549
srittauhttps://github.com/srittau
completedhttps://github.com/python/typing/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Nov 4, 2021https://github.com/python/typing/issues/269#event-5567309844
srittauhttps://github.com/srittau
resolution: out of scopeThe idea or discussion was out of scope for this repositoryhttps://github.com/python/typing/issues?q=state%3Aopen%20label%3A%22resolution%3A%20out%20of%20scope%22
topic: featureDiscussions about new features for Python's type annotationshttps://github.com/python/typing/issues?q=state%3Aopen%20label%3A%22topic%3A%20feature%22
enhancementhttps://github.com/python/typing/issues?q=state%3Aopen%20label%3A%22enhancement%22
on Nov 4, 2021https://github.com/python/typing/issues/269#event-5567310365
https://github.com/zzzeek
zzzeekhttps://github.com/zzzeek
on Jan 7, 2022https://github.com/python/typing/issues/269#issuecomment-1007824336
https://github.com/adam-grant-hendry
adam-grant-hendryhttps://github.com/adam-grant-hendry
on Sep 16, 2022https://github.com/python/typing/issues/269#issuecomment-1249680640
@JukkaLhttps://github.com/JukkaL
@dmoissethttps://github.com/dmoisset
@gvanrossumhttps://github.com/gvanrossum
@plcplchttps://github.com/plcplc
https://github.com/carlosgmartin
carlosgmartinhttps://github.com/carlosgmartin
on Nov 26, 2022https://github.com/python/typing/issues/269#issuecomment-1328094143
https://github.com/chriswithers-fuse
chriswithers-fusehttps://github.com/chriswithers-fuse
on Mar 16, 2026https://github.com/python/typing/issues/269#issuecomment-4067644442
Inheriting overloaded signatureshttps://github.com/python/mypy/issues/5146
Please document the need to redeclare overloadshttps://github.com/python/mypy/issues/10699
Proposed @overload(inherit=True)https://github.com/python/mypy/issues/9133
Inheriting Overloaded Signatureshttps://github.com/python/typing/discussions/1254
Method types not inherited when overriding overloaded methodhttps://github.com/microsoft/pyright/issues/10054
srittauhttps://github.com/srittau
on Mar 16, 2026https://github.com/python/typing/issues/269#event-23608847464
srittauhttps://github.com/srittau
resolution: out of scopeThe idea or discussion was out of scope for this repositoryhttps://github.com/python/typing/issues?q=state%3Aopen%20label%3A%22resolution%3A%20out%20of%20scope%22
on Mar 16, 2026https://github.com/python/typing/issues/269#event-23608851226
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/typing/issues/269
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/typing/issues/269
topic: featureDiscussions about new features for Python's type annotationshttps://github.com/python/typing/issues?q=state%3Aopen%20label%3A%22topic%3A%20feature%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.