Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dataclass initialization #48

Merged
merged 3 commits into from
Dec 8, 2021
Merged

Fix dataclass initialization #48

merged 3 commits into from
Dec 8, 2021

Conversation

dfurtado
Copy link
Owner

@dfurtado dfurtado commented Dec 4, 2021

This PR fixes a issue where the initialization of dataclass instance was dependent of the order which the columns of the CSV file was defined. For instance, a dataclass defined as:

@dataclass
class User:
    name: str
    email: str = "not specified"

The definition above required the CSV file to have the first column name and the second email, causing error or inconsistent data set the the dataclass fields.

Related issue: #47

Fix the dataclass initialization so the order of the members
of the dataclass doesn't need to match the order of the columns in
the CSV file.
That adds flexibility when non-required fields with default values needs
to be defined last in the dataclass.
Added a test case where the dataclass has a option field and the
fields of the dataclass are not in the same other as the columns of the
CSV file.
@dfurtado dfurtado merged commit 5f709c1 into master Dec 8, 2021
@dfurtado dfurtado deleted the dt-init-order branch December 8, 2021 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant