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

WrongTypeError - should be "str" instead of value ... of type "int" - Important when loading data from yaml #254

Open
JakeSummers opened this issue Apr 9, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@JakeSummers
Copy link

JakeSummers commented Apr 9, 2024

To Reproduce

def test_thing():

    @dataclass
    class Thing:
        foo: str

    input = yaml.safe_load(
        """
        foo: 8790666
        """
    )

    # WHEN
    dacite.from_dict(Thing, input)

    # THEN - NO EXCEPTION IS THROWN

Adding some characters into the test data, makes the above code work.

    input = yaml.safe_load(
        """
        foo: 8790666AAA
        """
    )

Expected behavior

No exception should be thrown.

Environment

  • Python version: 3.10.12
  • dacite version: 1.8.1

Additional context

I think that the same argument applied in #74 could apply here. :)

@JakeSummers JakeSummers added the bug Something isn't working label Apr 9, 2024
@JakeSummers JakeSummers changed the title dacite.exceptions.WrongTypeError: wrong value type for field ... - should be "str" instead of value ... of type "int" WrongTypeError - should be "str" instead of value ... of type "int" - Important when loading data from yaml Apr 9, 2024
@JakeSummers
Copy link
Author

After thinking about this a bit furter, I am not sure that this is a bug.

Updating the yaml from:

foo: 8790666

To:

foo: '8790666'

Resolves the problem.

It probably doesn't make sense to fix this issue. Suggestion: Close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant