From dc752ac7b90b8f6623e86a9aaa189a8f4d11f420 Mon Sep 17 00:00:00 2001 From: Joshua Morton Date: Fri, 25 Jan 2019 11:36:55 -0800 Subject: [PATCH 1/2] Improve the stubs in charset.pyi under python3. The python3 charset stubs didn't include certain necessary module level constansts (like `QP`) and too-tightly defined the arguments to some of the functions in the module. This is no longer the case. --- stdlib/3/email/charset.pyi | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/stdlib/3/email/charset.pyi b/stdlib/3/email/charset.pyi index 5c674e4520e8..36e2bbcb8c39 100644 --- a/stdlib/3/email/charset.pyi +++ b/stdlib/3/email/charset.pyi @@ -1,6 +1,10 @@ # Stubs for email.charset (Python 3.4) -from typing import List, Optional, Iterator, Any +from typing import List, Optional, Iterator, Any, Union + +QP: int +BASE64: int +SHORTEST: int class Charset: input_charset = ... # type: str @@ -20,7 +24,7 @@ class Charset: def __eq__(self, other: Any) -> bool: ... def __ne__(self, other: Any) -> bool: ... -def add_charset(charset: Charset, header_enc: Optional[int] = ..., +def add_charset(charset: Union[str, Charset], header_enc: Optional[int] = ..., body_enc: Optional[int] = ..., output_charset: Optional[str] = ...) -> None: ... def add_alias(alias: str, canonical: str) -> None: ... From 20413063e33ebb4fd694c8925321a2484cd9c94c Mon Sep 17 00:00:00 2001 From: Joshua Morton Date: Fri, 25 Jan 2019 11:53:45 -0800 Subject: [PATCH 2/2] Update add_charset to only take a string. On a second look, add_charset only accepts a string, it doesn't stringify the accepted object, so a Charset won't function correctly. --- stdlib/3/email/charset.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/3/email/charset.pyi b/stdlib/3/email/charset.pyi index 36e2bbcb8c39..979726607c38 100644 --- a/stdlib/3/email/charset.pyi +++ b/stdlib/3/email/charset.pyi @@ -1,6 +1,6 @@ # Stubs for email.charset (Python 3.4) -from typing import List, Optional, Iterator, Any, Union +from typing import List, Optional, Iterator, Any QP: int BASE64: int @@ -24,7 +24,7 @@ class Charset: def __eq__(self, other: Any) -> bool: ... def __ne__(self, other: Any) -> bool: ... -def add_charset(charset: Union[str, Charset], header_enc: Optional[int] = ..., +def add_charset(charset: str, header_enc: Optional[int] = ..., body_enc: Optional[int] = ..., output_charset: Optional[str] = ...) -> None: ... def add_alias(alias: str, canonical: str) -> None: ...