Make various email.Policy use sites generic over the message type#13274
Make various email.Policy use sites generic over the message type#13274srittau merged 5 commits intopython:mainfrom
email.Policy use sites generic over the message type#13274Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
The overloads in |
|
I just started getting a mypy error that I think is caused by the same issue, but it doesn't look like this PR touches Error: Code: |
|
mypy 1.15.0 also complains about Le mieux est l'ennemi du bien. |
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Fixes #13273
email.Policywas made generic in #12724. A bunch of places where its used don't provide an explicit type argument and use the default argument ofMessage. However, sinceemail.Policyis invariant in the message type, this causes problems when trying to passPolicyinstances that use subtypes ofMessage.This PR makes various places where
email.Policyis used generic in the message type, allowing the message type to be inferred instead of always defaulting toMessage.For context: