-
Notifications
You must be signed in to change notification settings - Fork 77
Open
Description
Hi there,
not quite sure what is going on, but this code doesn't type check for me in the Zed Editor.
# excerpt
from dataclasses import field
from typing import ClassVar, Type
import marshmallow as mm
from marshmallow_dataclass import dataclass
from controller.process_distribution.models import Document, Partner
@dataclass
class PostverteilungInput:
Schema: ClassVar[Type[mm.Schema]] = mm.Schema
partner: list[Partner] = field(
metadata={
"validate": mm.validate.Length(min=1),
"required": True,
},
)
dokument: Document = field(
metadata={"required": True},
)
geschuetzt: bool = field(metadata={"required": True}, default=False)

Putting the Schema variable as Schema: ClassVar[Type[mm.Schema]]
also doesn't help.
Shouldn't this type check? It seems that the type is insofar wrong, as mm.Schema.load()
does indeed not return the class PostverteilungInput
but only Unknown | list[Unknown] | dict[Unknown, Unknown] | None
. But this seems to be what the documentation recommends.
It seems I am missing something about how the typing is supposed to work here. :/
llucax
Metadata
Metadata
Assignees
Labels
No labels