Skip to content

Typing issue when extend_schema contained in dict literal #1145

@realsuayip

Description

@realsuayip

Describe the bug
I have a module where I maintain all extend_schema definitions like so:

from drf_spectacular.utils import extend_schema

a = extend_schema(summary="a")
b = extend_schema(summary="b")

f = {"a": a, "b": b}

Checking types gives following errors:

main.py:6: error: Dict entry 0 has incompatible type "str": "Callable[[F], F]"; expected "str": "Callable[[object], object]"  [dict-item]
main.py:6: 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)

To Reproduce
Run mypy>=1.6.0 on given Python script. The issue does not appear with mypy==1.5.1

Expected behavior
No errors?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions