typeshed
typeshed copied to clipboard
`clone()` declaration not overridden for `email.policy.EmailPolicy`
The clone() method of email.policy.EmailPolicy accepts keyword arguments for the properties that the class adds to Policy, but because there is no declaration of clone() under EmailPolicy in typeshed/std/email/policy.py, code like the following incorrectly fails to type-check under mypy 1.12:
from email import policy
assert policy.default.utf8 is False
p = policy.default.clone(utf8=True)
assert p.utf8 is True
clone-utf8.py:4: error: Unexpected keyword argument "utf8" for "clone" of "_PolicyBase" [call-arg]
/usr/local/Cellar/mypy/1.12.0/libexec/lib/python3.13/site-packages/mypy/typeshed/stdlib/email/_policybase.pyi:21: note: "clone" of "_PolicyBase" defined here
Indeed. PR welcome!