Navigation Menu

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

Same NameEmail field instances are not equal #1514

Closed
stephen-bunn opened this issue May 13, 2020 · 1 comment · Fixed by #1527
Closed

Same NameEmail field instances are not equal #1514

stephen-bunn opened this issue May 13, 2020 · 1 comment · Fixed by #1527
Labels
bug V1 Bug related to Pydantic V1.X

Comments

@stephen-bunn
Copy link
Contributor

Bug

Output of python -c "import pydantic.utils; print(pydantic.utils.version_info())":

             pydantic version: 1.5.1
            pydantic compiled: True
                 install path: /Users/***/.local/share/virtualenvs/tempenv-42b2286175873/lib/python3.7/site-packages/pydantic
               python version: 3.7.4 (default, Jul 22 2019, 11:21:52)  [Clang 10.0.1 (clang-1001.0.46.4)]
                     platform: Darwin-18.7.0-x86_64-i386-64bit
     optional deps. installed: ['email-validator']

I'm assuming that equality should be enforced on field types such as NameEmail. At the moment it seems that instances that appear to be equal are generating different hashes. Unsure if this is desired, but I would argue it shouldn't be.

import pydantic

# will raise an AssertionError
assert pydantic.NameEmail("test", "test@test.com") == pydantic.NameEmail("test", "test@test.com")
@stephen-bunn stephen-bunn added the bug V1 Bug related to Pydantic V1.X label May 13, 2020
@samuelcolvin
Copy link
Member

Thanks for reporting.

Happy to accept a PR to add a proper __eq__ method to NameEmail

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug V1 Bug related to Pydantic V1.X
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants