Skip to content

Same NameEmail field instances are not equal #1514

@stephen-bunn

Description

@stephen-bunn

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")

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug V1Bug related to Pydantic V1.X

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions