Title: Tk.report_callback_exception type annotation breaks subclass override compatibility · Issue #15840 · python/typeshed · GitHub
Open Graph Title: Tk.report_callback_exception type annotation breaks subclass override compatibility · Issue #15840 · python/typeshed
X Title: Tk.report_callback_exception type annotation breaks subclass override compatibility · Issue #15840 · python/typeshed
Description: Problem The current type annotation for Tk.report_callback_exception in typeshed, introduced in #2498, causes a regression when subclassing tkinter.Tk and overriding the method. Issue 1: Incompatible override error in pyright When subcla...
Open Graph Description: Problem The current type annotation for Tk.report_callback_exception in typeshed, introduced in #2498, causes a regression when subclassing tkinter.Tk and overriding the method. Issue 1: Incompatib...
X Description: Problem The current type annotation for Tk.report_callback_exception in typeshed, introduced in #2498, causes a regression when subclassing tkinter.Tk and overriding the method. Issue 1: Incompatib...
Opengraph URL: https://github.com/python/typeshed/issues/15840
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Tk.report_callback_exception type annotation breaks subclass override compatibility","articleBody":"## Problem\n\nThe current type annotation for `Tk.report_callback_exception` in typeshed, introduced in #2498, causes a regression when subclassing `tkinter.Tk` and overriding the method.\n\n### Issue 1: Incompatible override error in pyright\n\nWhen subclassing `Tk` and overriding `report_callback_exception` with the correct runtime signature, pyright reports an incompatible method override error.\n\n**Code:**\n```python\nfrom tkinter import Tk\nfrom types import TracebackType\nfrom typing import override\n\n\nclass App(Tk):\n @override\n def report_callback_exception(\n self,\n exc_type: type[BaseException],\n exc_value: BaseException,\n exc_traceback: TracebackType | None,\n ):\n pass\n```\n\n**pyright output:**\n```pwsh\n(report-callback-exception) PS G:\\programming\\python\\lab\\report_callback_exception> pyright\ng:\\programming\\python\\lab\\report_callback_exception\\main.py\n g:\\programming\\python\\lab\\report_callback_exception\\main.py:8:9 - error: Method \"report_callback_exception\" overrides class \"Tk\" in an incompatible manner\n Positional parameter count mismatch; base method has 3, but override has 4\n Parameter 2 type mismatch: base parameter is type \"BaseException\", override parameter is type \"type[BaseException]\"\n Parameter 3 type mismatch: base parameter is type \"TracebackType | None\", override parameter is type \"BaseException\"\n Type \"BaseException\" is not assignable to type \"type[BaseException]\"\n Type \"TracebackType | None\" is not assignable to type \"BaseException\"\n \"TracebackType\" is not assignable to \"BaseException\" (reportIncompatibleMethodOverride)\n1 error, 0 warnings, 0 informations\n```\n\n### Issue 2: Missing error on invalid manual call\n\nConversely, pyright does **not** report an error when manually calling `Tk.report_callback_exception` with the wrong signature, even though the code fails at runtime.\n\n**Code:**\n```python\nfrom tkinter import Tk\nimport sys\n\n\ndef main():\n try:\n print(0 / 0)\n except Exception:\n exc_type, exc_value, exc_traceback = sys.exc_info()\n assert exc_type is not None\n assert exc_value is not None\n Tk.report_callback_exception(exc_type, exc_value, exc_traceback)\n```\n\n**Runtime error:**\n```pwsh\n(report-callback-exception) PS G:\\programming\\python\\lab\\report_callback_exception> & g:\\programming\\python\\lab\\report_callback_exception\\.venv\\Scripts\\python.exe g:/programming/python/lab/report_callback_exception/main.py\nTraceback (most recent call last):\n File \"g:\\programming\\python\\lab\\report_callback_exception\\main.py\", line 7, in main\n 0 / 0\n ~~^~~\nZeroDivisionError: division by zero\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n File \"g:\\programming\\python\\lab\\report_callback_exception\\main.py\", line 16, in \u003cmodule>\n main()\n ~~~~^^\n File \"g:\\programming\\python\\lab\\report_callback_exception\\main.py\", line 12, in main\n Tk.report_callback_exception(exc_type, exc_value, exc_traceback)\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nTypeError: Tk.report_callback_exception() missing 1 required positional argument: 'tb'\n```\n\n**pyright output:**\n```pwsh\n(report-callback-exception) PS G:\\programming\\python\\lab\\report_callback_exception> pyright\n0 errors, 0 warnings, 0 informations\n```\n\n## Expected behavior\n\nThe type annotation should match the actual runtime signature as used in practice.\n\n## Additional context\n\n~~srittau said in https://github.com/python/typeshed/issues/1767#issuecomment-680798604:~~\n\n> ~~\"This looks more like a mypy problem to me. It is somehow expecting an additional self argument here.\"~~\n\n~~If that is indeed the case, I think we should revert the type annotation for `report_callback_exception` and report the error to mypy instead, because the root cause is not here.~~\n\nThe above statement is irrelevant to this issue.\n\nmypy's error when assigning to a method is [intentional](https://mypy.readthedocs.io/en/stable/error_code_list.html#check-that-assignment-target-is-not-a-method-method-assign), therefore #1767 is not an issue.\n\n","author":{"url":"https://github.com/Jesse205","@type":"Person","name":"Jesse205"},"datePublished":"2026-05-27T12:42:14Z","url":"https://github.com/python/typeshed/issues/15840"}
| react-profiling | 0 |
| react-import-map | react,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-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:57f266b3-653e-7314-4c01-ff3a8d28797f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8C44:5875E:21A4F0C:2DBA3B3:6B002396 |
| html-safe-nonce | cc163f6eb925a4f7aeddeef5ece6379e38e98e3c0952a9e7ee24d7ff7f150548 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QzQ0OjU4NzVFOjIxQTRGMEM6MkRCQTNCMzo2QjAwMjM5NiIsInZpc2l0b3JfaWQiOiIzOTI2MDkxNjgyMjMxMTAwMzEwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 60bfae20ef4645dba93da5d65fb5b18dbd09590df2715718521af9495549de35 |
| hovercard-subject-tag | issue:4532397296 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/typeshed/15840/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3491636a74e76dd500525e127e0ccb4b414e6e9876d982042526bf62f81cb51a/python/typeshed/issues/15840 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3491636a74e76dd500525e127e0ccb4b414e6e9876d982042526bf62f81cb51a/python/typeshed/issues/15840 |
| og:image:alt | Problem The current type annotation for Tk.report_callback_exception in typeshed, introduced in #2498, causes a regression when subclassing tkinter.Tk and overriding the method. Issue 1: Incompatib... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Jesse205 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4eb4cba0d69f045374ac15de9666d22b0961e1d555cc3824f36b7734c00c78e0 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/typeshed git https://github.com/python/typeshed.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 31696383 |
| octolytics-dimension-repository_nwo | python/typeshed |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 31696383 |
| octolytics-dimension-repository_network_root_nwo | python/typeshed |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 44c658b24abf00491fb7ae5f56d42c9f38cbeab2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width