René's URL Explorer Experiment


Title: Stubtest crashes on a stub with an overloaded method where the first overload is decorated with `@final` · Issue #14950 · python/mypy · GitHub

Open Graph Title: Stubtest crashes on a stub with an overloaded method where the first overload is decorated with `@final` · Issue #14950 · python/mypy

X Title: Stubtest crashes on a stub with an overloaded method where the first overload is decorated with `@final` · Issue #14950 · python/mypy

Description: Optional static typing for Python. Contribute to python/mypy development by creating an account on GitHub.

Open Graph Description: Optional static typing for Python. Contribute to python/mypy development by creating an account on GitHub.

X Description: Optional static typing for Python. Contribute to python/mypy development by creating an account on GitHub.

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Stubtest crashes on a stub with an overloaded method where the first overload is decorated with `@final`","articleBody":"**Crash Report**\r\n\r\nIf you run stubtest on a stub with a method like this, stubtest will crash:\r\n\r\n```python\r\nfrom typing import final, overload\r\n\r\nclass C:\r\n    @overload\r\n    @final\r\n    def foo(self, obj: str) -> int: ...\r\n    @overload\r\n    def foo(self, obj: int) -> str: ...\r\n```\r\n\r\nThe crash occurs regardless of the order in which you stack the `@final` and `@overload` decorator on the first overload. (PEP 591 specifies that for overloaded definitions in stubs, the `@final` decorator should be placed on the first overload, but doesn't specify which order they should be stacked in.)\r\n\r\n**Traceback**\r\n\r\n```pytb\r\nTraceback (most recent call last):\r\n  File \"\u003cfrozen runpy>\", line 198, in _run_module_as_main\r\n  File \"\u003cfrozen runpy>\", line 88, in _run_code\r\n  File \"C:\\Users\\alexw\\AppData\\Local\\Temp\\tmp_p_nrkoa\\Lib\\site-packages\\mypy\\stubtest.py\", line 1823, in \u003cmodule>\r\n    sys.exit(main())\r\n             ^^^^^^\r\n  File \"C:\\Users\\alexw\\AppData\\Local\\Temp\\tmp_p_nrkoa\\Lib\\site-packages\\mypy\\stubtest.py\", line 1819, in main\r\n    return test_stubs(parse_options(sys.argv[1:]))\r\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n  File \"C:\\Users\\alexw\\AppData\\Local\\Temp\\tmp_p_nrkoa\\Lib\\site-packages\\mypy\\stubtest.py\", line 1692, in test_stubs\r\n    for error in test_module(module):\r\n  File \"C:\\Users\\alexw\\AppData\\Local\\Temp\\tmp_p_nrkoa\\Lib\\site-packages\\mypy\\stubtest.py\", line 218, in test_module\r\n    yield from verify(stub, runtime, [module_name])\r\n  File \"C:\\Users\\alexw\\AppData\\Local\\Temp\\tmp_p_nrkoa\\Lib\\site-packages\\mypy\\stubtest.py\", line 396, in verify_mypyfile\r\n    yield from verify(stub_entry, runtime_entry, object_path + [entry])\r\n  File \"C:\\Users\\alexw\\AppData\\Local\\Temp\\tmp_p_nrkoa\\Lib\\site-packages\\mypy\\stubtest.py\", line 517, in verify_typeinfo\r\n    yield from verify(stub_to_verify, runtime_attr, object_path + [entry])\r\n  File \"C:\\Users\\alexw\\AppData\\Local\\Temp\\tmp_p_nrkoa\\Lib\\site-packages\\mypy\\stubtest.py\", line 1050, in verify_overloadedfuncdef\r\n    stub_sig = Signature.from_overloadedfuncdef(stub)\r\n               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n  File \"C:\\Users\\alexw\\AppData\\Local\\Temp\\tmp_p_nrkoa\\Lib\\site-packages\\mypy\\stubtest.py\", line 756, in from_overloadedfuncdef\r\n    assert func is not None\r\n           ^^^^^^^^^^^^^^^^\r\nAssertionError\r\n```\r\n\r\n**To Reproduce**\r\n\r\nTwo ways to reproduce:\r\n\r\n**(1) Apply this diff, and then run `pytest mypy/test/teststubtest.py`:**\r\n\r\n```diff\r\ndiff --git a/mypy/test/teststubtest.py b/mypy/test/teststubtest.py\r\nindex d39812b5f..b7f114b5e 100644\r\n--- a/mypy/test/teststubtest.py\r\n+++ b/mypy/test/teststubtest.py\r\n@@ -1177,6 +1177,24 @@ class StubtestUnit(unittest.TestCase):\r\n             \"\"\",\r\n             error=\"C\",\r\n         )\r\n+        yield Case(\r\n+            stub=\"\"\"\r\n+            from typing import overload\r\n+            from typing_extensions import final\r\n+            class D:\r\n+                @overload\r\n+                @final\r\n+                def foo(self, obj: int) -> str: ...\r\n+                @overload\r\n+                def foo(self, obj: str) -> int: ...\r\n+            \"\"\",\r\n+            runtime=\"\"\"\r\n+            class D:\r\n+                def foo(self, obj):\r\n+                    return 42 if isinstance(obj, str) else \"foo\"\r\n+            \"\"\",\r\n+            error=None\r\n+        )\r\n```\r\n\r\n**(2) With a typeshed clone checked out, apply this diff, then run `python tests/stubtest_stdlib.py`:**\r\n\r\n```diff\r\ndiff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi\r\nindex 2c21cd95d..8cdcd3b6a 100644\r\n--- a/stdlib/builtins.pyi\r\n+++ b/stdlib/builtins.pyi\r\n@@ -189,6 +189,7 @@ class type:\r\n\r\n class super:\r\n     @overload\r\n+    @final\r\n     def __init__(self, __t: Any, __obj: Any) -> None: ...\r\n     @overload\r\n     def __init__(self, __t: Any) -> None: ...\r\n```\r\n\r\n**Your Environment**\r\n\r\nReproduced with mypy 1.1.1 and mypy @ bfa9eacedb0554e1a6fe9245dbd5ccdbbc555fae\r\n","author":{"url":"https://github.com/AlexWaygood","@type":"Person","name":"AlexWaygood"},"datePublished":"2023-03-23T23:13:36Z","url":"https://github.com/python/mypy/issues/14950"}

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/:user_id/:repository/issues/:id(.:format)
route-controllerissues
route-actionshow
fetch-noncev2:fdfa3267-7538-c109-71fe-13ecddf87643
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idD1DC:1A3D7F:1C3D04E:245864C:6AFFC31E
html-safe-nonce291c3ff79f43eb9992211a036a24fe27499d69a7f4f1c3772168b4ab75181a7c
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMURDOjFBM0Q3RjoxQzNEMDRFOjI0NTg2NEM6NkFGRkMzMUUiLCJ2aXNpdG9yX2lkIjoiNDY4MzUzNjczNDI3NTc0ODYzOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacdb54c4a2b638779d1733a3be7550ceb8c86a05fff9fe145b5887242683c2bdc5
hovercard-subject-tagrepository:7053637
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///issues/show
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/python/mypy/issues/14950
twitter:imagehttps://opengraph.githubassets.com/850ce2019117db99c166b712132547c2dade118d4084179fa6a2ee39e584b4de/python/mypy
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/850ce2019117db99c166b712132547c2dade118d4084179fa6a2ee39e584b4de/python/mypy
og:image:altOptional static typing for Python. Contribute to python/mypy development by creating an account on GitHub.
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None1e805b832df235bb21305db712c3b6432920019dfc12cb25b9cb8d3b0c9403cf
turbo-cache-controlno-cache
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
release8fa4a54e6871c7908eda1c246ad5972982c0b59d
ui-targetcanary-2
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/mypy/issues/14950#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fmypy%2Fissues%2F14950
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%2F14950
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fissues%2Fshow&source=header-repo&source_repo=python%2Fmypy
Reloadhttps://github.com/python/mypy/issues/14950
Reloadhttps://github.com/python/mypy/issues/14950
Reloadhttps://github.com/python/mypy/issues/14950
https://github.com/python/mypy
New issuehttps://github.com/login?return_to=https://github.com/python/mypy/issues/14950
New issuehttps://github.com/login?return_to=https://github.com/python/mypy/issues/14950
#16457https://github.com/python/mypy/pull/16457
Stubtest crashes on a stub with an overloaded method where the first overload is decorated with @finalhttps://github.com/python/mypy/issues/14950#top
#16457https://github.com/python/mypy/pull/16457
crashhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22crash%22
topic-finalPEP 591https://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22topic-final%22
topic-stubtesthttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22topic-stubtest%22
https://github.com/AlexWaygood
AlexWaygoodhttps://github.com/AlexWaygood
on Mar 23, 2023https://github.com/python/mypy/issues/14950#issue-1638469061
bfa9eachttps://github.com/python/mypy/commit/bfa9eacedb0554e1a6fe9245dbd5ccdbbc555fae
AlexWaygoodhttps://github.com/AlexWaygood
crashhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22crash%22
topic-stubtesthttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22topic-stubtest%22
topic-finalPEP 591https://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22topic-final%22
on Mar 23, 2023https://github.com/python/mypy/issues/14950#event-8833277859
sobolevnhttps://github.com/sobolevn
on Mar 24, 2023https://github.com/python/mypy/issues/14950#event-8841223683
Stubtest: verify stub methods or properties are decorated with `@fina…https://github.com/python/mypy/commit/01a088b954ec9a0f351f4e9e9749896df8193830
01a088bhttps://github.com/python/mypy/commit/01a088b954ec9a0f351f4e9e9749896df8193830
hauntsaninjahttps://github.com/hauntsaninja
on Nov 11, 2023https://github.com/python/mypy/issues/14950#event-10931041396
stubtest: special case final and deprecatedhttps://github.com/hauntsaninja/mypy/commit/92cce1f944c3e179fc6ca80ce4c4ee4c6742e4c6
https://docs.github.com/articles/closing-issues-via-commit-messages
92cce1fhttps://github.com/hauntsaninja/mypy/commit/92cce1f944c3e179fc6ca80ce4c4ee4c6742e4c6
ilevkivskyihttps://github.com/ilevkivskyi
completedhttps://github.com/python/mypy/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#16457https://github.com/python/mypy/pull/16457
on Nov 11, 2023https://github.com/python/mypy/issues/14950#event-10933091928
ilevkivskyihttps://github.com/ilevkivskyi
on Nov 11, 2023https://github.com/python/mypy/issues/14950#event-10933091946
stubtest: special case final and deprecated (#16457)https://github.com/python/mypy/commit/8ae84edc3033c3cfa6a6dbfb920d859a9be4277d
#16457https://github.com/python/mypy/pull/16457
https://docs.github.com/articles/closing-issues-via-commit-messages
8ae84edhttps://github.com/python/mypy/commit/8ae84edc3033c3cfa6a6dbfb920d859a9be4277d
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/mypy/issues/14950
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/mypy/issues/14950
crashhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22crash%22
topic-finalPEP 591https://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22topic-final%22
topic-stubtesthttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22topic-stubtest%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.