Skip to content

"Type[xxx]" has no attribute "from_json" #23

@gjcarneiro

Description

@gjcarneiro

One of the downsides of @dataclass_json is that mypy doesn't know about the extra from_json and to_json methods. Any chance this can be supported, somehow?

The docs seem to suggest there is a plugin system in mypy, albeit experimental: https://mypy.readthedocs.io/en/latest/extending_mypy.html#extending-mypy-using-plugins

@dataclass_json
@dataclass
class BulkApmm:
    id: str
    frequency_ms: int
    pmms: List[Apmm]

...

    bulk_apmm = BulkApmm.from_json(await request.text())

betslipdisp/views.py:70: error: "Type[BulkApmm]" has no attribute "from_json"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions