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 NameEmail equality comparison #1527

Merged
merged 5 commits into from May 19, 2020

Conversation

stephen-bunn
Copy link
Contributor

@stephen-bunn stephen-bunn commented May 18, 2020

Change Summary

Introducing an __eq__ for networks.NameEmail as two similar instances were not being correctly evaluated as equal.

import pydantic

# previously this would raise an AssertionError
assert pydantic.NameEmail("test", "test@example.com") == pydantic.NameEmail("test", "test@example.com")1

Related issue number

closes #1514

Checklist

  • Unit tests for the changes exist
  • Tests pass on CI and coverage remains at 100%
  • Documentation reflects the changes where applicable
  • changes/<pull request or issue id>-<github username>.md file added describing change
    (see changes/README.md for details)

- Introducing new test assertions for NameEmail

Signed-off-by: Stephen Bunn <stephen@bunn.io>
Signed-off-by: Stephen Bunn <stephen@bunn.io>
@stephen-bunn stephen-bunn changed the title Name email equality Fix NameEmail equality comparison May 18, 2020
@codecov
Copy link

codecov bot commented May 18, 2020

Codecov Report

Merging #1527 into master will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##            master     #1527   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           21        21           
  Lines         3761      3772   +11     
  Branches       748       749    +1     
=========================================
+ Hits          3761      3772   +11     
Impacted Files Coverage Δ
pydantic/networks.py 100.00% <100.00%> (ø)
pydantic/utils.py 100.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5067508...9637c9c. Read the comment docs.

Copy link
Member

@samuelcolvin samuelcolvin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

otherwise LGTM

pydantic/networks.py Outdated Show resolved Hide resolved
tests/test_networks.py Outdated Show resolved Hide resolved
stephen-bunn and others added 3 commits May 18, 2020 17:55
Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
Signed-off-by: Stephen Bunn <stephen@bunn.io>
@samuelcolvin samuelcolvin merged commit 1eeb225 into pydantic:master May 19, 2020
@samuelcolvin
Copy link
Member

Awesome, thank you.

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.

Same NameEmail field instances are not equal
3 participants