Skip to content
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

Incorrect type inference when a decorator factory mentioned in dict literal #16794

Closed
realsuayip opened this issue Jan 18, 2024 · 2 comments
Closed
Labels
bug mypy got something wrong

Comments

@realsuayip
Copy link

Bug Report

When a decorator factory function is used in a dict literal, type inference fails. Adding explicit type fixes the issue but it's rather inconvenient. This bug seems to be introduced in mypy==1.6.0 since versions prior have no such issue.

To Reproduce

https://mypy-play.net/?mypy=latest&python=3.12&gist=f4e28d815f2832367905e3f4628b024a
https://gist.github.com/mypy-play/f4e28d815f2832367905e3f4628b024a

Expected Behavior

Mypy should infer the type correctly and no errors should be reported.

Actual Behavior

main.py:13: error: Dict entry 0 has incompatible type "str": "Callable[[F], F]"; expected "str": "Callable[[object], object]"  [dict-item]
main.py:13: error: Dict entry 1 has incompatible type "str": "Callable[[F], F]"; expected "str": "Callable[[object], object]"  [dict-item]
Found 2 errors in 1 file (checked 1 source file)

Your Environment

  • Mypy version used: 1.8
  • Python version used: 3.12
@hauntsaninja
Copy link
Collaborator

Looks like this was affected by #15837

@realsuayip
Copy link
Author

seems to be fixed in 1.11.0, probably via #17348

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

No branches or pull requests

2 participants