PynamoDB icon indicating copy to clipboard operation
PynamoDB copied to clipboard

mypy error [arg-type]: set nullable attributes to None

Open tonnico opened this issue 2 years ago • 0 comments

Looks like, there is something missing in the type definition if null=True. Before 6.0.0 this was not an issue.

from pynamodb.models import Model
from pynamodb.attributes import UnicodeAttribute


class Models(Model):
    class Meta:
        table_name = "table"

    hash_key = UnicodeAttribute(hash_key=True)
    nullable_key = UnicodeAttribute(null=True)


model = Models(hash_key="foo", nullable_key="bar")
model.save()
model.update(actions=[Models.nullable_key.set(None)])
# error: Argument 1 to "set" of "Attribute" has incompatible type "None"; expected "str | Attribute[str] | _Increment | _Decrement | _IfNotExists | _ListAppend"  [arg-type]

tonnico avatar Jan 15 '24 11:01 tonnico