René's URL Explorer Experiment


Title: Cannot assign to field of Callable type · Issue #708 · python/mypy · GitHub

Open Graph Title: Cannot assign to field of Callable type · Issue #708 · python/mypy

X Title: Cannot assign to field of Callable type · Issue #708 · python/mypy

Description: Consider this example: from typing import Callable class A: f = None # type: Callable[[int], int] def __init__(self, g: Callable[[int], int]) -> None: self.f = g mypy reports: trial.py: In member "__init__" of class "A": trial.py, line 7...

Open Graph Description: Consider this example: from typing import Callable class A: f = None # type: Callable[[int], int] def __init__(self, g: Callable[[int], int]) -> None: self.f = g mypy reports: trial.py: In member "...

X Description: Consider this example: from typing import Callable class A: f = None # type: Callable[[int], int] def __init__(self, g: Callable[[int], int]) -> None: self.f = g mypy reports: trial.py: In membe...

Opengraph URL: https://github.com/python/mypy/issues/708

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Cannot assign to field of Callable type","articleBody":"Consider this example:\n\n``` python\nfrom typing import Callable\n\nclass A:\n    f = None  # type: Callable[[int], int]\n\n    def __init__(self, g: Callable[[int], int]) -> None:\n        self.f = g\n```\n\nmypy reports:\n\n```\ntrial.py: In member \"__init__\" of class \"A\":\ntrial.py, line 7: Cannot assign to a method\ntrial.py, line 7: Invalid method type\ntrial.py, line 7: Incompatible types in assignment (expression has type Callable[[int], int], variable has type Callable[[], int])\n```\n\nwhile I'd expect this to work.\n\nNote that there is a second error in the reporting of the type of the variable.\n\nAlso, this passes type checking (correctly):\n\n``` python\nf = None  # type: Callable[[int], int]\n\ndef g(x: int) -> int: return 0\n\nf = g\n```\n","author":{"url":"https://github.com/spkersten","@type":"Person","name":"spkersten"},"datePublished":"2015-06-06T15:55:51Z","url":"https://github.com/python/mypy/issues/708"}

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:8c9814c9-59df-e3d9-8f84-c1614c8cf966
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idE184:B0403:EBD24B:1337A0F:6AFFF236
html-safe-noncec8d36009e451dad46fcc310587c6593925f79456429134c00557dd587260d2e0
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMTg0OkIwNDAzOkVCRDI0QjoxMzM3QTBGOjZBRkZGMjM2IiwidmlzaXRvcl9pZCI6Ijc4NjEyODkxNTYxNjc1NjI3OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac305e9239f73bbb37c16d61d76982846d2e191053ed38eea650366a6158323962
hovercard-subject-tagissue:85773757
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/mypy/708/issue_layout
twitter:imagehttps://opengraph.githubassets.com/488180a7f0573c2d1483756a40efa5a50e05c71a3afcd3d820ee159aa26e903a/python/mypy/issues/708
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/488180a7f0573c2d1483756a40efa5a50e05c71a3afcd3d820ee159aa26e903a/python/mypy/issues/708
og:image:altConsider this example: from typing import Callable class A: f = None # type: Callable[[int], int] def __init__(self, g: Callable[[int], int]) -> None: self.f = g mypy reports: trial.py: In member "...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamespkersten
hostnamegithub.com
expected-hostnamegithub.com
None0a0d8686a27478df474dd7415776a7a080cde8838b3cd92ea7601187572e5729
turbo-cache-controlno-preview
go-importgithub.com/python/mypy git https://github.com/python/mypy.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id7053637
octolytics-dimension-repository_nwopython/mypy
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id7053637
octolytics-dimension-repository_network_root_nwopython/mypy
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
release16a11879678aaf97e2a42c33ee70830aa084fa37
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/mypy/issues/708#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fmypy%2Fissues%2F708
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%2Fmypy%2Fissues%2F708
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%2Fmypy
Reloadhttps://github.com/python/mypy/issues/708
Reloadhttps://github.com/python/mypy/issues/708
Reloadhttps://github.com/python/mypy/issues/708
pythonhttps://github.com/python
mypyhttps://github.com/python/mypy
Codehttps://github.com/python/mypy
Issues2.7k (2.7k)https://github.com/python/mypy/issues
Pull requests547 (547)https://github.com/python/mypy/pulls
Actionshttps://github.com/python/mypy/actions
Projectshttps://github.com/python/mypy/projects
Wikihttps://github.com/python/mypy/wiki
Security and qualityhttps://github.com/python/mypy/security
Insightshttps://github.com/python/mypy/insights
https://github.com/python/mypy
New issuehttps://github.com/login?return_to=https://github.com/python/mypy/issues/708
New issuehttps://github.com/login?return_to=https://github.com/python/mypy/issues/708
#13400https://github.com/python/mypy/pull/13400
#10548https://github.com/python/mypy/pull/10548
Cannot assign to field of Callable typehttps://github.com/python/mypy/issues/708#top
#13400https://github.com/python/mypy/pull/13400
#10548https://github.com/python/mypy/pull/10548
affects-typeshedAnything that blocks a typeshed changehttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22affects-typeshed%22
bugmypy got something wronghttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22bug%22
false-positivemypy gave an error on correct codehttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22false-positive%22
priority-0-highhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22priority-0-high%22
size-largehttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22size-large%22
topic-descriptorsProperties, class vs. instance attributeshttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22topic-descriptors%22
https://github.com/spkersten
spkerstenhttps://github.com/spkersten
on Jun 6, 2015https://github.com/python/mypy/issues/708#issue-85773757
Nexthttps://github.com/python/mypy/issues/708?timeline_page=1
https://github.com/spkersten
spkerstenhttps://github.com/spkersten
on Jun 6, 2015https://github.com/python/mypy/issues/708#issuecomment-109608166
JukkaLhttps://github.com/JukkaL
bugmypy got something wronghttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22bug%22
priorityhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22priority%22
on Jun 7, 2015https://github.com/python/mypy/issues/708#event-324718276
https://github.com/JukkaL
JukkaLhttps://github.com/JukkaL
on Jun 7, 2015https://github.com/python/mypy/issues/708#issuecomment-109783888
JukkaLhttps://github.com/JukkaL
priorityhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22priority%22
on Jun 7, 2015https://github.com/python/mypy/issues/708#event-324721481
https://github.com/JukkaL
JukkaLhttps://github.com/JukkaL
on Jun 7, 2015https://github.com/python/mypy/issues/708#issuecomment-109783927
https://github.com/spkersten
spkerstenhttps://github.com/spkersten
on Jun 7, 2015https://github.com/python/mypy/issues/708#issuecomment-109784221
https://github.com/tharvik
tharvikhttps://github.com/tharvik
on Jul 29, 2016https://github.com/python/mypy/issues/708#issuecomment-236206421
ctypeshttps://docs.python.org/3/library/ctypes.html#function-prototypes
https://github.com/gvanrossum
gvanrossumhttps://github.com/gvanrossum
on Jul 29, 2016https://github.com/python/mypy/issues/708#issuecomment-236308826
https://github.com/gnprice
gnpricehttps://github.com/gnprice
on Aug 4, 2016https://github.com/python/mypy/issues/708#issuecomment-237684639
#1975https://github.com/python/mypy/issues/1975
https://github.com/gnprice
gnpricehttps://github.com/gnprice
on Aug 4, 2016https://github.com/python/mypy/issues/708#issuecomment-237684960
@tharvikhttps://github.com/tharvik
gnpricehttps://github.com/gnprice
on Aug 4, 2016https://github.com/python/mypy/issues/708#event-745893883
https://github.com/tharvik
tharvikhttps://github.com/tharvik
on Aug 5, 2016https://github.com/python/mypy/issues/708#issuecomment-237830356
@gnpricehttps://github.com/gnprice
foreign functionhttps://docs.python.org/3/library/ctypes.html#ctypes._FuncPtr.errcheck
loadedhttps://github.com/libLAS/libLAS/blob/77b2fc0279256f1e588818f36f4753b6a206047e/python/liblas/core.py#L158
checkshttps://github.com/libLAS/libLAS/blob/77b2fc0279256f1e588818f36f4753b6a206047e/python/liblas/core.py#L186
https://github.com/gvanrossum
gvanrossumhttps://github.com/gvanrossum
on Aug 5, 2016https://github.com/python/mypy/issues/708#issuecomment-237886580
gvanrossumhttps://github.com/gvanrossum
on Oct 17, 2016https://github.com/python/mypy/issues/708#event-826534585
ilevkivskyihttps://github.com/ilevkivskyi
on Aug 12, 2022https://github.com/python/mypy/issues/708#event-7182277226
Fix callable instance variable support (python#10548)https://github.com/ilevkivskyi/mypy/commit/8d517090c4a93590f8cf40c3ca23d8c0a7c81527
python#10548https://github.com/python/mypy/pull/10548
https://docs.github.com/articles/closing-issues-via-commit-messages
8d51709https://github.com/ilevkivskyi/mypy/commit/8d517090c4a93590f8cf40c3ca23d8c0a7c81527
ilevkivskyihttps://github.com/ilevkivskyi
completedhttps://github.com/python/mypy/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#13400https://github.com/python/mypy/pull/13400
on Aug 13, 2022https://github.com/python/mypy/issues/708#event-7182579214
ilevkivskyihttps://github.com/ilevkivskyi
on Aug 13, 2022https://github.com/python/mypy/issues/708#event-7182579233
Fix callable instance variable support (take 2) (#13400)https://github.com/python/mypy/commit/dc9c3040910d2d239f16a4e9d64c12f60b85afc6
#13400https://github.com/python/mypy/pull/13400
dc9c304https://github.com/python/mypy/commit/dc9c3040910d2d239f16a4e9d64c12f60b85afc6
deeplowhttps://github.com/deeplow
on Aug 16, 2022https://github.com/python/mypy/issues/708#event-7199234885
type hint application wrapper monkeypatchhttps://github.com/freedomofpress/dangerzone/commit/58a7e2b599efd8f40138d97e0f2f3409b9b0023f
58a7e2bhttps://github.com/freedomofpress/dangerzone/commit/58a7e2b599efd8f40138d97e0f2f3409b9b0023f
type hint application wrapper monkeypatchhttps://github.com/freedomofpress/dangerzone/commit/aec8a5892476c3a5bfc5097551041efed1c6d66e
aec8a58https://github.com/freedomofpress/dangerzone/commit/aec8a5892476c3a5bfc5097551041efed1c6d66e
type hint application wrapper monkeypatchhttps://github.com/freedomofpress/dangerzone/commit/2307c8257596889fdb8d16cbcf68bf211087a1bf
2307c82https://github.com/freedomofpress/dangerzone/commit/2307c8257596889fdb8d16cbcf68bf211087a1bf
type hint application wrapper monkeypatchhttps://github.com/freedomofpress/dangerzone/commit/bed808213d92818181812fc53af54892192f0e4b
bed8082https://github.com/freedomofpress/dangerzone/commit/bed808213d92818181812fc53af54892192f0e4b
type hint application wrapper monkeypatchhttps://github.com/freedomofpress/dangerzone/commit/75ce2441953de200d57aa944560f39c0095c1ce4
75ce244https://github.com/freedomofpress/dangerzone/commit/75ce2441953de200d57aa944560f39c0095c1ce4
zaniebhttps://github.com/zanieb
on Mar 24, 2023https://github.com/python/mypy/issues/708#event-8834457144
Ignore mypy errors due to method assignment during patchinghttps://github.com/zanieb/poetry-relax/commit/e8440b60b841c66e56f724a4efb1deaa66508d61
e8440b6https://github.com/zanieb/poetry-relax/commit/e8440b60b841c66e56f724a4efb1deaa66508d61
Ignore mypy errors due to method assignment during patchinghttps://github.com/zanieb/poetry-relax/commit/8f2ea106abe6defc3d2f68e4fd50327041df9248
8f2ea10https://github.com/zanieb/poetry-relax/commit/8f2ea106abe6defc3d2f68e4fd50327041df9248
https://github.com/kerimovkhikmet
kerimovkhikmethttps://github.com/kerimovkhikmet
on Aug 8, 2023https://github.com/python/mypy/issues/708#issuecomment-1669268049
#5062https://github.com/python/mypy/issues/5062
#5062 (comment)https://github.com/python/mypy/issues/5062#issue-323652082
Skitionekhttps://github.com/Skitionek
on Jan 8, 2024https://github.com/python/mypy/issues/708#event-11417747724
mypy wrongly checks type for attribute function assigment - updating …https://github.com/biosustain/lifelike/commit/be2808ab9d0ef2d4b4f5e8f1607ce69b84100a79
be2808ahttps://github.com/biosustain/lifelike/commit/be2808ab9d0ef2d4b4f5e8f1607ce69b84100a79
mypy wrongly checks type for attribute function assigment - updating …https://github.com/biosustain/lifelike/commit/f4e8c9fcf571b03884574ab58c9aa846f6d48536
f4e8c9fhttps://github.com/biosustain/lifelike/commit/f4e8c9fcf571b03884574ab58c9aa846f6d48536
mypy wrongly checks type for attribute function assigment - updating …https://github.com/biosustain/lifelike/commit/b0baae2523bf913c1e06c54fad3001886cfb3081
b0baae2https://github.com/biosustain/lifelike/commit/b0baae2523bf913c1e06c54fad3001886cfb3081
a0kumahttps://github.com/a0kuma
on Feb 11, 2026https://github.com/python/mypy/issues/708#event-22695838371
Correct type hint at Context.function using Protocolhttps://github.com/a0kuma/torchgpipeCheckpoint/commit/b8d1999ea64d8dfd31868e48e3cf96a99e64d6c3
b8d1999https://github.com/a0kuma/torchgpipeCheckpoint/commit/b8d1999ea64d8dfd31868e48e3cf96a99e64d6c3
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/mypy/issues/708
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/mypy/issues/708
affects-typeshedAnything that blocks a typeshed changehttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22affects-typeshed%22
bugmypy got something wronghttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22bug%22
false-positivemypy gave an error on correct codehttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22false-positive%22
priority-0-highhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22priority-0-high%22
size-largehttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22size-large%22
topic-descriptorsProperties, class vs. instance attributeshttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22topic-descriptors%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.