-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Description
https://github.com/samuelcolvin/pydantic/blob/master/pydantic/types.py#L669
if card_number.brand is (PaymentCardBrand.visa or PaymentCardBrand.mastercard)Assuming brand was reduced to the integers, and we had 3 brands, then this is the equivalent of:
3 is (1 or 2), which you'd hope were false, 1 is (1 or 2) which you'd hope were true, and 2 is (1 or 2) which you'd also hope were true. However, or short-circuits, so these reduce to 3 is 1, 1 is 1, and 2 is 1. This means the preferred outcome for the first two cases works, but it would fail for mastercard.
Perhaps this should be
if card_number.brand is PaymentCardBrand.visa or card_number.brand is PaymentCardBrand.mastercard:I think this was added relatively recently - 0c57937#diff-470d0730db2e82eaaf27ad3655a667b3R582 - so hopefully it hasn't affected too many people.
Metadata
Metadata
Assignees
Labels
No labels