Skip to content

Commit d8b0811

Browse files
authored
email.mime: add policy arguments (#3827)
1 parent 60c59a5 commit d8b0811

File tree

10 files changed

+107
-29
lines changed

10 files changed

+107
-29
lines changed
Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,28 @@
11
# Stubs for email.mime.application (Python 3.4)
22

3-
from typing import Callable, Optional, Tuple, Union
3+
import sys
44
from email.mime.nonmultipart import MIMENonMultipart
5+
from email.policy import Policy
6+
from typing import Callable, Optional, Tuple, Union
57

68
_ParamsType = Union[str, None, Tuple[str, Optional[str], str]]
79

810
class MIMEApplication(MIMENonMultipart):
9-
def __init__(self, _data: Union[str, bytes], _subtype: str = ...,
10-
_encoder: Callable[[MIMEApplication], None] = ...,
11-
**_params: _ParamsType) -> None: ...
11+
if sys.version_info >= (3, 6):
12+
def __init__(
13+
self,
14+
_data: Union[str, bytes],
15+
_subtype: str = ...,
16+
_encoder: Callable[[MIMEApplication], None] = ...,
17+
*,
18+
policy: Optional[Policy] = ...,
19+
**_params: _ParamsType,
20+
) -> None: ...
21+
else:
22+
def __init__(
23+
self,
24+
_data: Union[str, bytes],
25+
_subtype: str = ...,
26+
_encoder: Callable[[MIMEApplication], None] = ...,
27+
**_params: _ParamsType,
28+
) -> None: ...

stdlib/3/email/mime/audio.pyi

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,28 @@
11
# Stubs for email.mime.audio (Python 3.4)
22

3-
from typing import Callable, Optional, Tuple, Union
3+
import sys
44
from email.mime.nonmultipart import MIMENonMultipart
5+
from email.policy import Policy
6+
from typing import Callable, Optional, Tuple, Union
57

68
_ParamsType = Union[str, None, Tuple[str, Optional[str], str]]
79

810
class MIMEAudio(MIMENonMultipart):
9-
def __init__(self, _audiodata: Union[str, bytes], _subtype: Optional[str] = ...,
10-
_encoder: Callable[[MIMEAudio], None] = ...,
11-
**_params: _ParamsType) -> None: ...
11+
if sys.version_info >= (3, 6):
12+
def __init__(
13+
self,
14+
_audiodata: Union[str, bytes],
15+
_subtype: Optional[str] = ...,
16+
_encoder: Callable[[MIMEAudio], None] = ...,
17+
*,
18+
policy: Optional[Policy] = ...,
19+
**_params: _ParamsType,
20+
) -> None: ...
21+
else:
22+
def __init__(
23+
self,
24+
_audiodata: Union[str, bytes],
25+
_subtype: Optional[str] = ...,
26+
_encoder: Callable[[MIMEAudio], None] = ...,
27+
**_params: _ParamsType,
28+
) -> None: ...

stdlib/3/email/mime/base.pyi

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
# Stubs for email.mime.base (Python 3.4)
22

3-
from typing import Optional, Tuple, Union
43
import email.message
4+
import sys
5+
from email.policy import Policy
6+
from typing import Optional, Tuple, Union
57

68
_ParamsType = Union[str, None, Tuple[str, Optional[str], str]]
79

810
class MIMEBase(email.message.Message):
9-
def __init__(self, _maintype: str, _subtype: str,
10-
**_params: _ParamsType) -> None: ...
11+
if sys.version_info >= (3, 6):
12+
def __init__(self, _maintype: str, _subtype: str, *, policy: Optional[Policy] = ..., **_params: _ParamsType) -> None: ...
13+
else:
14+
def __init__(self, _maintype: str, _subtype: str, **_params: _ParamsType) -> None: ...

stdlib/3/email/mime/image.pyi

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,28 @@
11
# Stubs for email.mime.image (Python 3.4)
22

3-
from typing import Callable, Optional, Tuple, Union
3+
import sys
44
from email.mime.nonmultipart import MIMENonMultipart
5+
from email.policy import Policy
6+
from typing import Callable, Optional, Tuple, Union
57

68
_ParamsType = Union[str, None, Tuple[str, Optional[str], str]]
79

810
class MIMEImage(MIMENonMultipart):
9-
def __init__(self, _imagedata: Union[str, bytes], _subtype: Optional[str] = ...,
10-
_encoder: Callable[[MIMEImage], None] = ...,
11-
**_params: _ParamsType) -> None: ...
11+
if sys.version_info >= (3, 6):
12+
def __init__(
13+
self,
14+
_imagedata: Union[str, bytes],
15+
_subtype: Optional[str] = ...,
16+
_encoder: Callable[[MIMEImage], None] = ...,
17+
*,
18+
policy: Optional[Policy] = ...,
19+
**_params: _ParamsType,
20+
) -> None: ...
21+
else:
22+
def __init__(
23+
self,
24+
_imagedata: Union[str, bytes],
25+
_subtype: Optional[str] = ...,
26+
_encoder: Callable[[MIMEImage], None] = ...,
27+
**_params: _ParamsType,
28+
) -> None: ...

stdlib/3/email/mime/message.pyi

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
# Stubs for email.mime.message (Python 3.4)
22

3+
import sys
34
from email.message import Message
45
from email.mime.nonmultipart import MIMENonMultipart
6+
from email.policy import Policy
7+
from typing import Optional
58

69
class MIMEMessage(MIMENonMultipart):
7-
def __init__(self, _msg: Message, _subtype: str = ...) -> None: ...
10+
if sys.version_info >= (3, 6):
11+
def __init__(self, _msg: Message, _subtype: str = ..., *, policy: Optional[Policy] = ...) -> None: ...
12+
else:
13+
def __init__(self, _msg: Message, _subtype: str = ...) -> None: ...

stdlib/3/email/mime/multipart.pyi

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,29 @@
11
# Stubs for email.mime.multipart (Python 3.4)
22

3-
from typing import Optional, Sequence, Tuple, Union
3+
import sys
44
from email.message import Message
55
from email.mime.base import MIMEBase
6+
from email.policy import Policy
7+
from typing import Optional, Sequence, Tuple, Union
68

79
_ParamsType = Union[str, None, Tuple[str, Optional[str], str]]
810

911
class MIMEMultipart(MIMEBase):
10-
def __init__(self, _subtype: str = ..., boundary: Optional[str] = ...,
11-
_subparts: Optional[Sequence[Message]] = ...,
12-
**_params: _ParamsType) -> None: ...
12+
if sys.version_info >= (3, 6):
13+
def __init__(
14+
self,
15+
_subtype: str = ...,
16+
boundary: Optional[str] = ...,
17+
_subparts: Optional[Sequence[Message]] = ...,
18+
*,
19+
policy: Optional[Policy] = ...,
20+
**_params: _ParamsType,
21+
) -> None: ...
22+
else:
23+
def __init__(
24+
self,
25+
_subtype: str = ...,
26+
boundary: Optional[str] = ...,
27+
_subparts: Optional[Sequence[Message]] = ...,
28+
**_params: _ParamsType,
29+
) -> None: ...

stdlib/3/email/mime/text.pyi

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
# Stubs for email.mime.text (Python 3.4)
22

3-
from typing import Optional
3+
import sys
44
from email.mime.nonmultipart import MIMENonMultipart
5+
from email.policy import Policy
6+
from typing import Optional
57

68
class MIMEText(MIMENonMultipart):
7-
def __init__(self, _text: str, _subtype: str = ...,
8-
_charset: Optional[str] = ...) -> None: ...
9+
if sys.version_info >= (3, 6):
10+
def __init__(
11+
self, _text: str, _subtype: str = ..., _charset: Optional[str] = ..., *, policy: Optional[Policy] = ...
12+
) -> None: ...
13+
else:
14+
def __init__(self, _text: str, _subtype: str = ..., _charset: Optional[str] = ...) -> None: ...

tests/stubtest_whitelists/py36.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ collections.abc.AsyncGenerator.ag_running
2727
copy.PyStringMap
2828
ctypes.CDLL.__init__
2929
email.message.MIMEPart.as_string
30-
email.mime.message.MIMEMessage.__init__
31-
email.mime.text.MIMEText.__init__
3230
enum.Enum._generate_next_value_
3331
gettext.NullTranslations.npgettext
3432
gettext.NullTranslations.pgettext

tests/stubtest_whitelists/py37.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ dataclasses.dataclass
4545
dataclasses.field
4646
dataclasses.make_dataclass
4747
email.message.MIMEPart.as_string
48-
email.mime.message.MIMEMessage.__init__
49-
email.mime.text.MIMEText.__init__
5048
enum.Enum._generate_next_value_
5149
gettext.NullTranslations.npgettext
5250
gettext.NullTranslations.pgettext

tests/stubtest_whitelists/py38.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,6 @@ decimal.Decimal.from_float
9999
decimal.setcontext
100100
dis.stack_effect
101101
email.message.MIMEPart.as_string
102-
email.mime.message.MIMEMessage.__init__
103-
email.mime.text.MIMEText.__init__
104102
enum.Enum._generate_next_value_
105103
functools.partialmethod.__get__
106104
gettext.install

0 commit comments

Comments
 (0)