Skip to content

Type check ignored on a dictionary #20791

@danmur97

Description

@danmur97

Bug Report

Type check is ignored on keys and values of a dictionary when declared in a specific way.

To Reproduce

playground example

Mypy detects the error whenever Util.constructor or Util.apply is not used. But if both are used the calls to f used on the keys or values are not type checked.

Expected Behavior
error: Argument 1 has incompatible type "str"; expected "int" [arg-type] at the calls of f

Actual Behavior

Mypy does not throw arg-type errors
Your Environment

checkout playground example

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongtopic-type-contextType context / bidirectional inference

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions