Skip to content

TYPE_CHECKING overload with implementation just outside flags second usage, but not first #19015

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
graingert opened this issue May 2, 2025 · 2 comments · May be fixed by #19042
Open

TYPE_CHECKING overload with implementation just outside flags second usage, but not first #19015

graingert opened this issue May 2, 2025 · 2 comments · May be fixed by #19042
Labels
bug mypy got something wrong

Comments

@graingert
Copy link
Contributor

graingert commented May 2, 2025

Bug Report

TYPE_CHECKING overload with implementation just outside flags second usage, but not first

To Reproduce

https://mypy-play.net/?mypy=latest&python=3.12&gist=9aa50566df450052503989e5bba6a3c7

Expected Behavior
No errors (or errors on all use of overload)

Actual Behavior

main.py:14: error: An overloaded function outside a stub file must have an implementation  [no-overload-impl]
main.py:20: error: Name "spam" already defined on line 14  [no-redef]
Found 2 errors in 1 file (checked 1 source file)

Your Environment

see playground url

@graingert graingert added the bug mypy got something wrong label May 2, 2025
@graingert
Copy link
Contributor Author

@sterliakov
Copy link
Collaborator

I'll try to have a look. As a quick workaround, you can slap another function between two overloads: https://mypy-play.net/?mypy=latest&python=3.12&gist=392de84669f2156225b16c183df085d4

@sterliakov sterliakov linked a pull request May 6, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants