Skip to content

Catch type error on django models #52

Closed
@ivanrvpereira

Description

@ivanrvpereira

It is possible to have type errors for django models?

class A(models.Model):
    pass

class B(models.Model):
    pass

def service(a: A) -> int:
    pass

a_instance = A()
b_instance = B()
service(b)  # no type error

It would help a lot if this could be caught earlier on the editor.
Because all models inherit from models.Model and

Every class is also a valid type. Any instance of a subclass is also compatible with all superclasses

I' m trying to figure if there is an option to detect this errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions