Skip to content

Incorrect typing for ManyToMany add() #997

@markedwards

Description

@markedwards

Bug report

What's wrong

The typing of a ManyToMany relation's add() method incorrectly assumes that model ids are int, but they can be other types, such as UUID. Attempting to call add(model_id) causes a mypy error if the id is not an int:

Argument 1 has incompatible type "UUID"; expected "Union[FooModel, int]"

How is that should be

The add() method should accept the related model, and whatever the type of the related model's id is.

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