René's URL Explorer Experiment


Title: Let function signature hook have context of caller · Issue #14845 · python/mypy · GitHub

Open Graph Title: Let function signature hook have context of caller · Issue #14845 · python/mypy

X Title: Let function signature hook have context of caller · Issue #14845 · python/mypy

Description: When executing (plugin) function signature hooks, actual argument types are not available yet (and, in fact, there's no caller context). In #14526, the signature of attr.evolve(inst, ...) depended on the inst argument, and we had no choi...

Open Graph Description: When executing (plugin) function signature hooks, actual argument types are not available yet (and, in fact, there's no caller context). In #14526, the signature of attr.evolve(inst, ...) depended ...

X Description: When executing (plugin) function signature hooks, actual argument types are not available yet (and, in fact, there's no caller context). In #14526, the signature of attr.evolve(inst, ...) depen...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Let function signature hook have context of caller","articleBody":"When executing (plugin) function signature hooks, actual argument types are not available yet (and, in fact, there's no caller context).\r\n\r\nIn #14526, the signature of `attr.evolve(inst, ...)` depended on the `inst` argument, and we had no choice but to do\r\n```python\r\ninst_arg = ctx.args[0][0]\r\n\r\nassert isinstance(ctx.api, TypeChecker)\r\ninst_type = ctx.api.expr_checker.accept(inst_arg)\r\n```\r\n\r\nActual argument types are passed to the **function hook**, but then it's too late since arguments were already checked, and the hook can only affect the callee's return type.\r\n\r\nI'm not sure what's the best approach:\r\n\r\n1. Add equivalent of `CheckerPluginInterface.accept` for ad-hoc type resolution (i.e. current solution but w/o private API). The assumption is that this will not normally be used by hook authors except in specific cases for specific args (since doing it generally creates a chicken-and-egg problem, as `infer_arg_types_in_context` gets the callee after the hook's mutation).\r\n2. Pass actual arg types to **function sig hook**. Not sure it'll be doable, since as I mentioned `infer_arg_types_in_context` depends on `callee` (after hook's mutation).\r\n3. Change **function hook** to allow returning not only a ret_type but also arg_types/kinds/names. This means that in those cases checks will be done twice: it first has to pass old formal sig, then (if plugin returns one) it has to pass the new formal sig.\r\n\r\nPlease advise :)\r\n\r\nP.S. Same applies to method signature hook.","author":{"url":"https://github.com/ikonst","@type":"Person","name":"ikonst"},"datePublished":"2023-03-06T16:28:53Z","url":"https://github.com/python/mypy/issues/14845"}

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:7d7c77a7-138b-c6d9-87d5-cba6dba710c8
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idE7EE:24D752:4525F9:5D5C5A:6B002C88
html-safe-nonce199873aca1edfed3f77de83602d7f5d5b634290be5a99eb57048b93c40752571
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFN0VFOjI0RDc1Mjo0NTI1Rjk6NUQ1QzVBOjZCMDAyQzg4IiwidmlzaXRvcl9pZCI6IjY2NjcyMDY0ODk5MDU1NzMwMDAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac8a253d4ea8afdfd7abc30b876b57ae4512bb2afb579a57acbb74bf7663928371
hovercard-subject-tagissue:1611798664
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/14845/issue_layout
twitter:imagehttps://opengraph.githubassets.com/00032060ba889b231eacff6e2a63f8bd4917507ba87e667679f5de1a8ad83fb3/python/mypy/issues/14845
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/00032060ba889b231eacff6e2a63f8bd4917507ba87e667679f5de1a8ad83fb3/python/mypy/issues/14845
og:image:altWhen executing (plugin) function signature hooks, actual argument types are not available yet (and, in fact, there's no caller context). In #14526, the signature of attr.evolve(inst, ...) depended ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameikonst
hostnamegithub.com
expected-hostnamegithub.com
None7d0829bbde9e48b2486cb5dd6d147896eb01d32134627091f818958a935ef3f0
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
releasef3f3a43ca095cdea3abbb394112e971f9fdb94fa
ui-targetcanary-1
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/mypy/issues/14845#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fmypy%2Fissues%2F14845
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%2F14845
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/14845
Reloadhttps://github.com/python/mypy/issues/14845
Reloadhttps://github.com/python/mypy/issues/14845
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/14845
New issuehttps://github.com/login?return_to=https://github.com/python/mypy/issues/14845
#15369https://github.com/python/mypy/pull/15369
Let function signature hook have context of callerhttps://github.com/python/mypy/issues/14845#top
#15369https://github.com/python/mypy/pull/15369
featurehttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22feature%22
topic-pluginsThe plugin API and ideas for new pluginshttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22topic-plugins%22
https://github.com/ikonst
ikonsthttps://github.com/ikonst
on Mar 6, 2023https://github.com/python/mypy/issues/14845#issue-1611798664
#14526https://github.com/python/mypy/pull/14526
ikonsthttps://github.com/ikonst
featurehttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22feature%22
on Mar 6, 2023https://github.com/python/mypy/issues/14845#event-8676373262
AlexWaygoodhttps://github.com/AlexWaygood
topic-pluginsThe plugin API and ideas for new pluginshttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22topic-plugins%22
on Mar 6, 2023https://github.com/python/mypy/issues/14845#event-8676604010
https://github.com/ikonst
ikonsthttps://github.com/ikonst
on Mar 7, 2023https://github.com/python/mypy/issues/14845#issuecomment-1457483080
https://github.com/ikonst
ikonsthttps://github.com/ikonst
on Mar 7, 2023https://github.com/python/mypy/issues/14845#issuecomment-1457535993
#10216https://github.com/python/mypy/issues/10216
ilevkivskyihttps://github.com/ilevkivskyi
completedhttps://github.com/python/mypy/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#15369https://github.com/python/mypy/pull/15369
on Jun 11, 2023https://github.com/python/mypy/issues/14845#event-9494164099
ilevkivskyihttps://github.com/ilevkivskyi
on Jun 11, 2023https://github.com/python/mypy/issues/14845#event-9494164225
Add get_expression_type to CheckerPluginInterface (#15369)https://github.com/python/mypy/commit/a108c670c395c719e81cd87674654daf54ec95ee
#15369https://github.com/python/mypy/pull/15369
https://docs.github.com/articles/closing-issues-via-commit-messages
a108c67https://github.com/python/mypy/commit/a108c670c395c719e81cd87674654daf54ec95ee
Add signature for dataclasses.replace (#14849)https://github.com/python/mypy/commit/6f2bfff521e708f015af1eec5118db4600b829be
#14849https://github.com/python/mypy/pull/14849
https://docs.github.com/articles/closing-issues-via-commit-messages
6f2bfffhttps://github.com/python/mypy/commit/6f2bfff521e708f015af1eec5118db4600b829be
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/mypy/issues/14845
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/mypy/issues/14845
featurehttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22feature%22
topic-pluginsThe plugin API and ideas for new pluginshttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22topic-plugins%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.