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

Issue with dictionary & lambda & get function #16148

Closed
Sanchoyzer opened this issue Sep 19, 2023 · 1 comment
Closed

Issue with dictionary & lambda & get function #16148

Sanchoyzer opened this issue Sep 19, 2023 · 1 comment
Labels
bug mypy got something wrong

Comments

@Sanchoyzer
Copy link

Bug Report

For some reason, mypy doesn't handle working with a dictionary, a lambda function, and the get function correctly.

To Reproduce

from typing import Callable


def test_me(my_dict: dict | None = None) -> None:
    def _f(func: Callable) -> None:
        func('a')

    if my_dict is not None:
        _f(lambda x: my_dict.get(x))

Gist, Playgroud

Actual Behavior

error: Item "None" of "dict[Any, Any] | None" has no attribute "get" [union-attr]

Your Environment

  • Python 3.11.4
  • mypy 1.5.1
@Sanchoyzer Sanchoyzer added the bug mypy got something wrong label Sep 19, 2023
@hauntsaninja
Copy link
Collaborator

Thanks, duplicate of #16056

@hauntsaninja hauntsaninja closed this as not planned Won't fix, can't repro, duplicate, stale Sep 21, 2023
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