Skip to content

When type hint is not recognized (e.g. pd.Timestamp), we recursively try to convert into a dataclass which mutates the constructor throughout the codebase #51

@evanfwelch

Description

@evanfwelch

Reproducible error:

import pandas as pd
import dataclasses

import marshmallow_dataclass

@dataclasses.dataclass
class Something:
    date_i_care_about: pd.Timestamp

print(f"here's a timestamp {pd.Timestamp('2017-01-01')}")

# this mutates the constructor for pd.Timestamp by recursively trying to convert to dataclass
marshmallow_dataclass.class_schema(Something)

print(f"here's a timestamp {pd.Timestamp('2017-01-01')}")

versions:
pandas 0.23.4
marshmallow 2.x
marshmallow_dataclass: 0.6.6

@lovasoa what is the intution behind trying to convert clazz to dataclass here after we fail to get the fields?

https://github.com/lovasoa/marshmallow_dataclass/blob/master/marshmallow_dataclass/__init__.py#L281

I feel that an error (or some kind of strict mode) would be more helpful

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