René's URL Explorer Experiment


Title: warn_no_return = False: handle implicit "return None" (not ignoring return type) · Issue #7511 · python/mypy · GitHub

Open Graph Title: warn_no_return = False: handle implicit "return None" (not ignoring return type) · Issue #7511 · python/mypy

X Title: warn_no_return = False: handle implicit "return None" (not ignoring return type) · Issue #7511 · python/mypy

Description: warn_no_return is on by default, but does not take into account that None is returned explicitly. I think it should maybe only warn if the return type does not include None (i.e. uses typing.Optional). Given t_mypy.py: import typing def ...

Open Graph Description: warn_no_return is on by default, but does not take into account that None is returned explicitly. I think it should maybe only warn if the return type does not include None (i.e. uses typing.Option...

X Description: warn_no_return is on by default, but does not take into account that None is returned explicitly. I think it should maybe only warn if the return type does not include None (i.e. uses typing.Option...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"warn_no_return = False: handle implicit \"return None\" (not ignoring return type)","articleBody":"`warn_no_return` is on by default, but does not take into account that `None` is returned explicitly.\r\n\r\nI think it should maybe only warn if the return type does not include `None` (i.e. uses `typing.Optional`).\r\n\r\nGiven t_mypy.py:\r\n\r\n```python\r\nimport typing\r\n\r\n\r\ndef no_return_optional(arg) -> typing.Optional[str]:\r\n    if arg:\r\n        return \"false\"\r\n\r\n\r\ndef no_return(arg) -> str:\r\n    if arg:\r\n        return \"false\"\r\n\r\n\r\na1 = no_return_optional(True)\r\na2 = no_return_optional(False)\r\nreveal_type(a1)\r\nreveal_type(a2)\r\n\r\nb1 = no_return(True)\r\nb2 = no_return(False)\r\nreveal_type(b1)\r\nreveal_type(b2)\r\n```\r\n\r\n`mypy --warn-no-return` shows:\r\n\r\n```\r\nt_mypy.py:4: error: Missing return statement\r\nt_mypy.py:9: error: Missing return statement\r\nt_mypy.py:16: note: Revealed type is 'Union[builtins.str, None]'\r\nt_mypy.py:17: note: Revealed type is 'Union[builtins.str, None]'\r\nt_mypy.py:21: note: Revealed type is 'builtins.str'\r\nt_mypy.py:22: note: Revealed type is 'builtins.str'\r\nFound 2 errors in 1 file (checked 1 source file)\r\n```\r\n\r\n`mypy --no-warn-no-return` does not show any error, but should warn/error about the missing return statement / wrong return value for `no_return` (which is annotated to return `str`, but might return `None`).\r\n\r\nmypy 0.730+dev.28423cd78062b81365ec9aaa591b4e823af1606d","author":{"url":"https://github.com/blueyed","@type":"Person","name":"blueyed"},"datePublished":"2019-09-13T22:19:50Z","url":"https://github.com/python/mypy/issues/7511"}

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:31499ff6-1913-e353-0e4f-b7691f46bdf5
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idCBCC:106F5D:FC67D9:153CB12:6B005E14
html-safe-nonce140e73bcc1aa30eff3d32d12c3b1bfb2a648cc27b5d7d8a56575646722af3d8e
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQkNDOjEwNkY1RDpGQzY3RDk6MTUzQ0IxMjo2QjAwNUUxNCIsInZpc2l0b3JfaWQiOiIzMzgwODM4ODQwOTA1MjYwNTY0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac33d6237fb91882bf0221bec0b6f1e6a2c40511943787a20c57f1f8a967b54c92
hovercard-subject-tagissue:493538094
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/7511/issue_layout
twitter:imagehttps://opengraph.githubassets.com/0911f57cb1bf62da8bc3826ea9a71c77e97ea5ffa1db2414ff10da30c2bd40a2/python/mypy/issues/7511
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/0911f57cb1bf62da8bc3826ea9a71c77e97ea5ffa1db2414ff10da30c2bd40a2/python/mypy/issues/7511
og:image:altwarn_no_return is on by default, but does not take into account that None is returned explicitly. I think it should maybe only warn if the return type does not include None (i.e. uses typing.Option...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameblueyed
hostnamegithub.com
expected-hostnamegithub.com
None29be975efff6507a5d135de9c7d634cf7ff8f0c55222a64386ab3202209aaf73
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
releaseeacd927ba6112e3b01ba99c762bd699a4a4f5df7
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/mypy/issues/7511#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fmypy%2Fissues%2F7511
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%2F7511
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/7511
Reloadhttps://github.com/python/mypy/issues/7511
Reloadhttps://github.com/python/mypy/issues/7511
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 requests545 (545)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/7511
New issuehttps://github.com/login?return_to=https://github.com/python/mypy/issues/7511
#13219https://github.com/python/mypy/pull/13219
warn_no_return = False: handle implicit "return None" (not ignoring return type)https://github.com/python/mypy/issues/7511#top
#13219https://github.com/python/mypy/pull/13219
documentationhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22documentation%22
needs discussionhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22needs%20discussion%22
topic-usabilityhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22topic-usability%22
https://github.com/blueyed
blueyedhttps://github.com/blueyed
on Sep 13, 2019https://github.com/python/mypy/issues/7511#issue-493538094
Nexthttps://github.com/python/mypy/issues/7511?timeline_page=1
https://github.com/JukkaL
JukkaLhttps://github.com/JukkaL
on Sep 16, 2019https://github.com/python/mypy/issues/7511#issuecomment-531784286
JukkaLhttps://github.com/JukkaL
documentationhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22documentation%22
needs discussionhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22needs%20discussion%22
topic-usabilityhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22topic-usability%22
on Sep 16, 2019https://github.com/python/mypy/issues/7511#event-2636462887
blueyedhttps://github.com/blueyed
on Nov 26, 2019https://github.com/python/mypy/issues/7511#event-2830897893
https://github.com/blueyed
blueyedhttps://github.com/blueyed
on Nov 26, 2019https://github.com/python/mypy/issues/7511#issuecomment-558512068
https://mypy.readthedocs.io/en/latest/command_line.html#cmdoption-mypy-no-warn-no-returnhttps://mypy.readthedocs.io/en/latest/command_line.html#cmdoption-mypy-no-warn-no-return
https://github.com/ilevkivskyi
ilevkivskyihttps://github.com/ilevkivskyi
on Nov 26, 2019https://github.com/python/mypy/issues/7511#issuecomment-558651235
https://github.com/blueyed
blueyedhttps://github.com/blueyed
on Nov 26, 2019https://github.com/python/mypy/issues/7511#issuecomment-558778497
@ilevkivskyihttps://github.com/ilevkivskyi
https://github.com/ilevkivskyi
ilevkivskyihttps://github.com/ilevkivskyi
on Nov 26, 2019https://github.com/python/mypy/issues/7511#issuecomment-558783130
https://github.com/blueyed
blueyedhttps://github.com/blueyed
on Nov 29, 2019https://github.com/python/mypy/issues/7511#issuecomment-559624989
https://github.com/ofek
ofekhttps://github.com/ofek
on Jun 1, 2020https://github.com/python/mypy/issues/7511#issuecomment-636570274
#3974 (comment)https://github.com/python/mypy/issues/3974#issuecomment-331648044
https://github.com/JukkaL
JukkaLhttps://github.com/JukkaL
on Jun 8, 2020https://github.com/python/mypy/issues/7511#issuecomment-640665509
https://github.com/ofek
ofekhttps://github.com/ofek
on Jun 9, 2020https://github.com/python/mypy/issues/7511#issuecomment-641073968
@JukkaLhttps://github.com/JukkaL
#8975https://github.com/python/mypy/issues/8975
https://github.com/WhyNotHugo
WhyNotHugohttps://github.com/WhyNotHugo
on Sep 9, 2020https://github.com/python/mypy/issues/7511#issuecomment-689526006
https://github.com/gvanrossum
gvanrossumhttps://github.com/gvanrossum
on Sep 9, 2020https://github.com/python/mypy/issues/7511#issuecomment-689642560
https://github.com/PedanticHacker
PedanticHackerhttps://github.com/PedanticHacker
on Jul 5, 2021https://github.com/python/mypy/issues/7511#issuecomment-874135228
https://github.com/svet-b
svet-bhttps://github.com/svet-b
on Jul 5, 2021https://github.com/python/mypy/issues/7511#issuecomment-874167736
@PedanticHackerhttps://github.com/PedanticHacker
the docshttps://mypy.readthedocs.io/en/stable/error_code_list.html#check-that-function-returns-a-value-return
pyrighthttps://github.com/microsoft/pyright
https://github.com/PedanticHacker
PedanticHackerhttps://github.com/PedanticHacker
on Jul 5, 2021https://github.com/python/mypy/issues/7511#issuecomment-874361331
https://github.com/gwerbin
gwerbinhttps://github.com/gwerbin
on Sep 10, 2021https://github.com/python/mypy/issues/7511#issuecomment-916578011
kovidgoyalhttps://github.com/kovidgoyal
on Oct 26, 2021https://github.com/python/mypy/issues/7511#event-5522160867
mypy: Turn on return value checkshttps://github.com/kovidgoyal/kitty/commit/4494ddd8ff67c48ae612920a595eb39ae79d91cb
4494dddhttps://github.com/kovidgoyal/kitty/commit/4494ddd8ff67c48ae612920a595eb39ae79d91cb
https://github.com/0xfede7c8
0xfede7c8https://github.com/0xfede7c8
on Jun 3, 2022https://github.com/python/mypy/issues/7511#issuecomment-1146313784
hauntsaninjahttps://github.com/hauntsaninja
on Jul 23, 2022https://github.com/python/mypy/issues/7511#event-7049680626
Check implicit None return is valid when using `--no-warn-no-return`https://github.com/hauntsaninja/mypy/commit/c7a3fc4ab415276468bc2be00837b0bac9cbf28a
https://docs.github.com/articles/closing-issues-via-commit-messages
c7a3fc4https://github.com/hauntsaninja/mypy/commit/c7a3fc4ab415276468bc2be00837b0bac9cbf28a
https://github.com/hauntsaninja
hauntsaninjahttps://github.com/hauntsaninja
on Jul 23, 2022https://github.com/python/mypy/issues/7511#issuecomment-1193034833
#13219https://github.com/python/mypy/pull/13219
hauntsaninjahttps://github.com/hauntsaninja
completedhttps://github.com/python/mypy/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#13219https://github.com/python/mypy/pull/13219
on Jul 27, 2022https://github.com/python/mypy/issues/7511#event-7069434904
hauntsaninjahttps://github.com/hauntsaninja
on Jul 27, 2022https://github.com/python/mypy/issues/7511#event-7069434955
Check implicit None return is valid when using `--no-warn-no-return` (#…https://github.com/python/mypy/commit/c02ec4a5b51e66239bbd11e4da6a8edf7e3e6f04
#…https://github.com/python/mypy/pull/13219
https://docs.github.com/articles/closing-issues-via-commit-messages
c02ec4ahttps://github.com/python/mypy/commit/c02ec4a5b51e66239bbd11e4da6a8edf7e3e6f04
Julianhttps://github.com/Julian
on Jan 5, 2023https://github.com/python/mypy/issues/7511#event-8164571204
Improve mypy's behavior for implicit returns.https://github.com/python-jsonschema/referencing/commit/d2cab08b419afcdd4f43b3e8c514d6b64da559ba
d2cab08https://github.com/python-jsonschema/referencing/commit/d2cab08b419afcdd4f43b3e8c514d6b64da559ba
hauntsaninjahttps://github.com/hauntsaninja
on Sep 13, 2023https://github.com/python/mypy/issues/7511#event-10355950432
Warn for missing returns with explicit Any return typeshttps://github.com/hauntsaninja/mypy/commit/bb5d43924930413129be55838c26ccdf2dfe2701
bb5d439https://github.com/hauntsaninja/mypy/commit/bb5d43924930413129be55838c26ccdf2dfe2701
morimura07https://github.com/morimura07
on Jul 2, 2025https://github.com/python/mypy/issues/7511#event-18421639342
Improve mypy's behavior for implicit returns.https://github.com/morimura07/referencing/commit/82c70e58f2da682691c90cdee821b4e73ee0ea5b
82c70e5https://github.com/morimura07/referencing/commit/82c70e58f2da682691c90cdee821b4e73ee0ea5b
mistery220https://github.com/mistery220
on Oct 28, 2025https://github.com/python/mypy/issues/7511#event-20550764321
Improve mypy's behavior for implicit returns.https://github.com/mistery220/referencing/commit/349fcc3e1c58f46de5d1f2431e4a17e23fc11532
349fcc3https://github.com/mistery220/referencing/commit/349fcc3e1c58f46de5d1f2431e4a17e23fc11532
zcheehttps://github.com/zchee
on Jul 8, 2026https://github.com/python/mypy/issues/7511#event-27693682622
mypy: Turn on return value checkshttps://github.com/zchee/kitty/commit/37c750ce90aafe4391d99c3d909de5eee1899cde
37c750chttps://github.com/zchee/kitty/commit/37c750ce90aafe4391d99c3d909de5eee1899cde
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/mypy/issues/7511
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/mypy/issues/7511
documentationhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22documentation%22
needs discussionhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22needs%20discussion%22
topic-usabilityhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22topic-usability%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.