Skip to content

Incompatible types in assignment for document fields #602

Open
@ericbuehl

Description

@ericbuehl

What is the bug?

Using v2.4.1, types on fields are not inferred correctly when setting from instance methods

How can one reproduce the bug?

a contrived example:

class MyDocument(Document):
    myVal = Double()

    def save(self, **kwargs):
        # set default value for myVal
        if not self.myVal:
            self.myVal = 1
        return super().save(**kwargs)

running mypy would yield:

error: Incompatible types in assignment (expression has type "int", variable has type "Double")  [assignment]

What is the expected behavior?

no type error

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