Skip to content

Incompatible type with many=True #260

Open
@christianbundy

Description

@christianbundy

Bug report

What's wrong

class MySerializer(serializers.Serializer[int]): ...

MySerializer([1,2,3], many=True)
error: Argument 1 to "MySerializer" has incompatible type "List[int]"; expected "Optional[int]"  [arg-type]

How is that should be

Success: no issues found in 1 source file

System information

  • OS: Linux f16759b1b324 5.10.104-linuxkit #1 SMP PREEMPT Thu Mar 17 17:05:54 UTC 2022 aarch64 GNU/Linux
  • python version: 3.10.6
  • django version: 4.0.7
  • mypy version: 0.961
  • django-stubs version: 1.12.0

Also, it isn't asked for by the template, but:

  • djangorestframework version: 3.13.1
  • djangorestframework-stubs version: 1.7.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions