Title: Regression: overload signatures with default parameters no longer reported as overlapping · Issue #18581 · python/mypy · GitHub
Open Graph Title: Regression: overload signatures with default parameters no longer reported as overlapping · Issue #18581 · python/mypy
X Title: Regression: overload signatures with default parameters no longer reported as overlapping · Issue #18581 · python/mypy
Description: Bug Report Since 1.11.0 and up to current master mypy no longer reports overloads in the snippet below as overlapping. 1.10.1 detects the overlap correctly. According to the recent typing spec update for overloads, this is a bug: If two ...
Open Graph Description: Bug Report Since 1.11.0 and up to current master mypy no longer reports overloads in the snippet below as overlapping. 1.10.1 detects the overlap correctly. According to the recent typing spec upda...
X Description: Bug Report Since 1.11.0 and up to current master mypy no longer reports overloads in the snippet below as overlapping. 1.10.1 detects the overlap correctly. According to the recent typing spec upda...
Opengraph URL: https://github.com/python/mypy/issues/18581
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Regression: overload signatures with default parameters no longer reported as overlapping","articleBody":"**Bug Report**\n\nSince 1.11.0 and up to current master `mypy` no longer reports overloads in the snippet below as overlapping. 1.10.1 detects the overlap correctly.\n\nAccording to the recent [typing spec update](https://github.com/python/typing/pull/1839/files) for overloads, this is a bug:\n\n> If two overloads can accept the same set of arguments, they are said to \"partially overlap\". If two overloads partially overlap, the return type of the former overload should be assignable to the return type of the latter overload. If this condition doesn't hold, it is indicative of a programming error and should be reported by type checkers.\n\nThis bisects to #17392 - this false negative was missed there. cc @ilevkivskyi \n\n**To Reproduce**\n\nhttps://mypy-play.net/?mypy=1.11.0&python=3.10&flags=strict&gist=9f4be4dac4c302b9d556746cdbffa251\n\n```python\nfrom typing import overload\n\n@overload\ndef fn(x: str = ...) -> str: ...\n@overload\ndef fn(x: int = ...) -> int: ...\ndef fn(x: int | str = 0) -> int | str:\n return x\n```\n\n**Expected Behavior**\n\nSince `fn()` is allowed for both signatures, they overlap, so 1.10.1 output should remain there:\n\n```text\nmain.py:4: error: Overloaded function signatures 1 and 2 overlap with incompatible return types [overload-overlap]\n```\n\n**Actual Behavior**\n\nMypy accepts the snippet.\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.11.0 through current master vs 1.10.1\n- Mypy command-line flags: --strict and without\n- Mypy configuration options from `mypy.ini` (and other config files): n/a\n- Python version used: 3.12\n","author":{"url":"https://github.com/sterliakov","@type":"Person","name":"sterliakov"},"datePublished":"2025-02-01T19:59:42Z","url":"https://github.com/python/mypy/issues/18581"}
| 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:e9cdc04a-9a33-cddd-5fb6-178b1eace145 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D970:1B0A31:216D607:2D76541:6B002565 |
| html-safe-nonce | be30863aca78ef009f4678e82b27726f06fb3c9c600e76e733a4886232aa4472 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEOTcwOjFCMEEzMToyMTZENjA3OjJENzY1NDE6NkIwMDI1NjUiLCJ2aXNpdG9yX2lkIjoiNjc2ODk4NTk5MjA3MTIyNjcyNSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | bcf5c629d5e81d7762d00b8a12991540fe59b52540550e020fbbb7bd983c396b |
| hovercard-subject-tag | issue:2825399568 |
| 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/18581/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ccf344130bc56089a2060dac407cf8f9872011d8c9039d7fdd79d1d958c192e6/python/mypy/issues/18581 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ccf344130bc56089a2060dac407cf8f9872011d8c9039d7fdd79d1d958c192e6/python/mypy/issues/18581 |
| og:image:alt | Bug Report Since 1.11.0 and up to current master mypy no longer reports overloads in the snippet below as overlapping. 1.10.1 detects the overlap correctly. According to the recent typing spec upda... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sterliakov |
| 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