From 35b84f2f21c9a8410a63bf47794cb2b1fe1f66aa Mon Sep 17 00:00:00 2001 From: Max Muoto Date: Sat, 13 Jul 2024 16:08:28 -0500 Subject: [PATCH] Update `email.utils` for 3.13 (#12336) Co-authored-by: Jelle Zijlstra --- stdlib/@tests/stubtest_allowlists/py313.txt | 2 -- stdlib/email/utils.pyi | 17 +++++++++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/stdlib/@tests/stubtest_allowlists/py313.txt b/stdlib/@tests/stubtest_allowlists/py313.txt index ec09ae8ed888..7b253f536e85 100644 --- a/stdlib/@tests/stubtest_allowlists/py313.txt +++ b/stdlib/@tests/stubtest_allowlists/py313.txt @@ -37,8 +37,6 @@ ctypes.wintypes.PCHAR.from_param ctypes.wintypes.PWCHAR.from_param doctest.TestResults.__doc__ doctest.TestResults.__new__ -email.utils.getaddresses -email.utils.parseaddr filecmp.dircmp.__init__ importlib.resources.Anchor importlib.resources.Resource diff --git a/stdlib/email/utils.pyi b/stdlib/email/utils.pyi index 0b62647532db..2724dbf6ec2f 100644 --- a/stdlib/email/utils.pyi +++ b/stdlib/email/utils.pyi @@ -1,6 +1,7 @@ import datetime import sys from _typeshed import Unused +from collections.abc import Iterable from email import _ParamType from email.charset import Charset from typing import overload @@ -28,9 +29,21 @@ _PDTZ: TypeAlias = tuple[int, int, int, int, int, int, int, int, int, int | None def quote(str: str) -> str: ... def unquote(str: str) -> str: ... -def parseaddr(addr: str | None) -> tuple[str, str]: ... + +if sys.version_info >= (3, 13): + def parseaddr(addr: str | list[str], *, strict: bool = True) -> tuple[str, str]: ... + +else: + def parseaddr(addr: str) -> tuple[str, str]: ... + def formataddr(pair: tuple[str | None, str], charset: str | Charset = "utf-8") -> str: ... -def getaddresses(fieldvalues: list[str]) -> list[tuple[str, str]]: ... + +if sys.version_info >= (3, 13): + def getaddresses(fieldvalues: Iterable[str], *, strict: bool = True) -> list[tuple[str, str]]: ... + +else: + def getaddresses(fieldvalues: Iterable[str]) -> list[tuple[str, str]]: ... + @overload def parsedate(data: None) -> None: ... @overload