Title: Mypy false positive for `converter` class attribute in `logging.Formatter` class. · Issue #19241 · python/mypy · GitHub
Open Graph Title: Mypy false positive for `converter` class attribute in `logging.Formatter` class. · Issue #19241 · python/mypy
X Title: Mypy false positive for `converter` class attribute in `logging.Formatter` class. · Issue #19241 · python/mypy
Description: Bug Report Mypy false positive: Mypy thinks that setting the converter class attribute for a subclass of logging.Formatter to something like time.gmtime is wrong. To Reproduce class UTCFormatter(logging.Formatter): """An exact match for ...
Open Graph Description: Bug Report Mypy false positive: Mypy thinks that setting the converter class attribute for a subclass of logging.Formatter to something like time.gmtime is wrong. To Reproduce class UTCFormatter(lo...
X Description: Bug Report Mypy false positive: Mypy thinks that setting the converter class attribute for a subclass of logging.Formatter to something like time.gmtime is wrong. To Reproduce class UTCFormatter(lo...
Opengraph URL: https://github.com/python/mypy/issues/19241
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Mypy false positive for `converter` class attribute in `logging.Formatter` class.","articleBody":"\u003c!--\nIf you're not sure whether what you're experiencing is a mypy bug, please see the \"Question and Help\" form instead.\nPlease consider:\n\n- checking our common issues page: https://mypy.readthedocs.io/en/stable/common_issues.html\n- searching our issue tracker: https://github.com/python/mypy/issues to see if it's already been reported\n- asking on gitter chat: https://gitter.im/python/typing\n-->\n\n**Bug Report**\n\n\u003c!--\nIf you're reporting a problem with a specific library function, the typeshed tracker is better suited for this report: https://github.com/python/typeshed/issues\n\nIf the project you encountered the issue in is open source, please provide a link to the project.\n-->\n\nMypy false positive: Mypy thinks that setting the converter class attribute for a subclass of `logging.Formatter` to something like `time.gmtime` is wrong.\n\n**To Reproduce**\n\n```python\nclass UTCFormatter(logging.Formatter):\n \"\"\"An exact match for the `logging.Formatter` class, except that it logs the time in UTC.\"\"\"\n converter = time.gmtime\n```\n\n**Expected Behavior**\nNo error, since time.gmtime is annotated as `def gmtime(seconds: float | None = None, /) -> struct_time: ...` and the converter attribute is annotated as ` converter: Callable[[float | None], struct_time]`.\n\n\u003c!--\nHow did you expect mypy to behave? It’s fine if you’re not sure your understanding is correct.\nWrite down what you thought would happen. If you expected no errors, delete this section.\n-->\n\n**Actual Behavior**\n\n\u003c!-- What went wrong? Paste mypy's output. -->\nlogger.py:45: error: Incompatible types in assignment (expression has type \"Callable[[], struct_time]\", base class \"Formatter\" defined the type as \"Callable[[float | None], struct_time]\") [assignment]\n\n**Your Environment**\n\n\u003c!-- Include as many relevant details about the environment you experienced the bug in -->\n\n- Mypy version used: 1.16.0 (compiled: yes)\n- Mypy command-line flags: None\n- Mypy configuration options from `mypy.ini` (and other config files): None\n- Python version used: 3.13.4 (on Linux)\n\nBy the way, this issue didn't exist in my Python3.12 environment with an older version of mypy installed, but I don't have access to that environment right now so I can't provide which mypy version it had.\n\u003c!-- You can freely edit this text, please remove all the lines you believe are unnecessary. -->\n","author":{"url":"https://github.com/Yazan-Sharaya","@type":"Person","name":"Yazan-Sharaya"},"datePublished":"2025-06-06T02:01:10Z","url":"https://github.com/python/mypy/issues/19241"}
| 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:c3dee215-1514-382a-0154-32002bbc08cd |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B0D4:3E4AC7:211758F:2CC4CDB:6B001D78 |
| html-safe-nonce | 332eef8b4033ffe884e53ff1b2595f3c4b8b4de25a2c8d86a02cd7d93ef26e5b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMEQ0OjNFNEFDNzoyMTE3NThGOjJDQzRDREI6NkIwMDFENzgiLCJ2aXNpdG9yX2lkIjoiMjc5NTIxMjY5MjgxNjY2NTk3NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 8dc2d3e041ec98a9947fc031a67777c28f2ef3fbb8eb2f3432281126d323aea2 |
| hovercard-subject-tag | issue:3123382809 |
| 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/mypy/19241/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1a07812c1d3ca0bc6cb77f804283a69d352e9d84dc1ea1eb0f4f61fe2d9f5b7c/python/mypy/issues/19241 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1a07812c1d3ca0bc6cb77f804283a69d352e9d84dc1ea1eb0f4f61fe2d9f5b7c/python/mypy/issues/19241 |
| og:image:alt | Bug Report Mypy false positive: Mypy thinks that setting the converter class attribute for a subclass of logging.Formatter to something like time.gmtime is wrong. To Reproduce class UTCFormatter(lo... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Yazan-Sharaya |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4eb4cba0d69f045374ac15de9666d22b0961e1d555cc3824f36b7734c00c78e0 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/mypy git https://github.com/python/mypy.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 7053637 |
| octolytics-dimension-repository_nwo | python/mypy |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 7053637 |
| octolytics-dimension-repository_network_root_nwo | python/mypy |
| 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