mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 12:44:28 +08:00
Mypy now supports sys.platform and sys.version_info checks (#410)
This commit is contained in:
@@ -2,7 +2,9 @@
|
||||
|
||||
from typing import Callable, Optional, IO
|
||||
import sys
|
||||
from email.message import Message, Policy
|
||||
from email.message import Message
|
||||
if sys.version_info >= (3, 3):
|
||||
from email.policy import Policy
|
||||
|
||||
if sys.version_info >= (3, 3):
|
||||
def message_from_string(s: str, _class: Callable[[], Message] = ..., *,
|
||||
@@ -15,16 +17,16 @@ if sys.version_info >= (3, 3):
|
||||
_class: Callable[[], Message] = ..., *,
|
||||
policy: Policy = ...) -> Message: ...
|
||||
elif sys.version_info >= (3, 2):
|
||||
def message_from_string(s: str, # type: ignore
|
||||
def message_from_string(s: str,
|
||||
_class: Callable[[], Message] = ..., *,
|
||||
strict: Optional[bool] = ...) -> Message: ...
|
||||
def message_from_bytes(s: bytes, # type: ignore
|
||||
def message_from_bytes(s: bytes,
|
||||
_class: Callable[[], Message] = ..., *,
|
||||
strict: Optional[bool] = ...) -> Message: ...
|
||||
def message_from_file(fp: IO[str], # type: ignore
|
||||
def message_from_file(fp: IO[str],
|
||||
_class: Callable[[], Message] = ..., *,
|
||||
strict: Optional[bool] = ...) -> Message: ...
|
||||
def message_from_binary_file(fp: IO[bytes], # type: ignore
|
||||
def message_from_binary_file(fp: IO[bytes],
|
||||
_class: Callable[[], Message] = ..., *,
|
||||
strict: Optional[bool] = ...) -> Message: ...
|
||||
|
||||
|
||||
@@ -3,14 +3,15 @@
|
||||
from typing import Callable
|
||||
import sys
|
||||
from email.message import Message
|
||||
from email.policy import Policy
|
||||
if sys.version_info >= (3, 3):
|
||||
from email.policy import Policy
|
||||
|
||||
class FeedParser:
|
||||
if sys.version_info >= (3, 3):
|
||||
def __init__(self, _factory: Callable[[], Message] = ..., *,
|
||||
policy: Policy = ...) -> None: ...
|
||||
else:
|
||||
def __init__(self, # type: ignore
|
||||
def __init__(self,
|
||||
_factory: Callable[[], Message] = ...) -> None: ...
|
||||
def feed(self, data: str) -> None: ...
|
||||
def close(self) -> Message: ...
|
||||
@@ -21,7 +22,7 @@ if sys.version_info >= (3, 2):
|
||||
def __init__(self, _factory: Callable[[], Message] = ..., *,
|
||||
policy: Policy = ...) -> None: ...
|
||||
else:
|
||||
def __init__(self, # type: ignore
|
||||
def __init__(self,
|
||||
_factory: Callable[[], Message] = ...) -> None: ...
|
||||
def feed(self, data: str) -> None: ...
|
||||
def close(self) -> Message: ...
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
|
||||
from typing import TextIO, Optional
|
||||
import sys
|
||||
from email.policy import Policy
|
||||
from email.message import Message
|
||||
if sys.version_info >= (3, 3):
|
||||
from email.policy import Policy
|
||||
|
||||
class Generator:
|
||||
def clone(self, fp: TextIO) -> 'Generator': ...
|
||||
@@ -13,14 +14,14 @@ class Generator:
|
||||
maxheaderlen: int = ..., *,
|
||||
policy: Policy = ...) -> None: ...
|
||||
else:
|
||||
def __init__(self, outfp: TextIO, # type: ignore
|
||||
def __init__(self, outfp: TextIO,
|
||||
mangle_from_: bool = ...,
|
||||
maxheaderlen: int = ...) -> None: ...
|
||||
if sys.version_info >= (3, 2):
|
||||
def flatten(self, msg: Message, unixfrom: bool = ...,
|
||||
linesep: Optional[str] =...) -> None: ...
|
||||
else:
|
||||
def flatten(self, msg: Message, # type: ignore
|
||||
def flatten(self, msg: Message,
|
||||
unixfrom: bool = ...) -> None: ...
|
||||
|
||||
if sys.version_info >= (3, 2):
|
||||
@@ -32,7 +33,7 @@ if sys.version_info >= (3, 2):
|
||||
maxheaderlen: int = ..., *,
|
||||
policy: Policy = ...) -> None: ...
|
||||
else:
|
||||
def __init__(self, outfp: TextIO, # type: ignore
|
||||
def __init__(self, outfp: TextIO,
|
||||
mangle_from_: bool = ...,
|
||||
maxheaderlen: int = ...) -> None: ...
|
||||
def flatten(self, msg: Message, unixfrom: bool = ...,
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
# Stubs for email.headerregistry (Python 3.4)
|
||||
|
||||
from typing import Tuple, Optional, Any, Union, Mapping
|
||||
import sys
|
||||
from email.errors import MessageDefect
|
||||
from email.policy import Policy
|
||||
import datetime as dt
|
||||
import sys
|
||||
from typing import Tuple, Optional, Any, Union, Mapping
|
||||
from email.errors import MessageDefect
|
||||
if sys.version_info >= (3, 3):
|
||||
from email.policy import Policy
|
||||
|
||||
if sys.version_info >= (3, 3):
|
||||
|
||||
|
||||
@@ -6,8 +6,12 @@ from typing import (
|
||||
import sys
|
||||
from email.charset import Charset
|
||||
from email.errors import MessageDefect
|
||||
from email.policy import Policy
|
||||
from email.contentmanager import ContentManager
|
||||
if sys.version_info >= (3, 3):
|
||||
from email.policy import Policy
|
||||
if sys.version_info >= (3, 4):
|
||||
from email.contentmanager import ContentManager
|
||||
else:
|
||||
ContentManager = object # Hack so we can reference it in argument types.
|
||||
|
||||
_T = TypeVar('_T')
|
||||
|
||||
@@ -75,50 +79,21 @@ class Message:
|
||||
requote: bool = ..., charset: str = ...,
|
||||
language: str = ..., replace: bool = ...) -> None: ...
|
||||
else:
|
||||
def as_string(self, unixfrom: bool = ..., # type: ignore
|
||||
def as_string(self, unixfrom: bool = ...,
|
||||
maxheaderlen: int = ...) -> str: ...
|
||||
def set_param(self, param: str, value: str, # type: ignore
|
||||
def set_param(self, param: str, value: str,
|
||||
header: str = ..., requote: bool = ...,
|
||||
charset: str = ..., language: str = ...) -> None: ...
|
||||
if sys.version_info >= (3, 3):
|
||||
def __init__(self, policy: Policy = ...) -> None: ...
|
||||
else:
|
||||
def __init__(self) -> None: ... # type: ignore
|
||||
|
||||
class EmailMessage:
|
||||
def __init__(self, policy: Policy = ...) -> None: ...
|
||||
def get_body(self,
|
||||
preferencelist: Sequence[str] = ...) -> Optional[Message]: ...
|
||||
def iter_attachments(self) -> Iterator[Message]: ...
|
||||
def iter_parts(self) -> Iterator[Message]: ...
|
||||
def get_content(self, *args: Any,
|
||||
content_manager: Optional[ContentManager] = ...,
|
||||
**kw: Any) -> Any: ...
|
||||
def set_content(self, *args: Any,
|
||||
content_manager: Optional[ContentManager] = ...,
|
||||
**kw: Any) -> None: ...
|
||||
def make_related(self, boundary: Optional[str] = ...) -> None: ...
|
||||
def make_alternative(self, boundary: Optional[str] = ...) -> None: ...
|
||||
def make_mixed(self, boundary: Optional[str] = ...) -> None: ...
|
||||
def add_related(self, *args: Any,
|
||||
content_manager: Optional[ContentManager] = ...,
|
||||
**kw: Any) -> None: ...
|
||||
def add_alternative(self, *args: Any,
|
||||
content_manager: Optional[ContentManager] = ...,
|
||||
**kw: Any) -> None: ...
|
||||
def add_attachement(self, *args: Any,
|
||||
content_manager: Optional[ContentManager] = ...,
|
||||
**kw: Any) -> None: ...
|
||||
def clear(self) -> None: ...
|
||||
def clear_content(self) -> None: ...
|
||||
if sys.version_info >= (3, 4, 2):
|
||||
def is_attachment(self) -> bool: ...
|
||||
else:
|
||||
@property
|
||||
def is_attachment(self) -> bool: ...
|
||||
def __init__(self) -> None: ...
|
||||
|
||||
class MIMEPart:
|
||||
def __init__(self, policy: Policy = ...) -> None: ...
|
||||
if sys.version_info >= (3, 3):
|
||||
def __init__(self, policy: Policy = ...) -> None: ...
|
||||
else:
|
||||
def __init__(self) -> None: ...
|
||||
def get_body(self,
|
||||
preferencelist: Sequence[str] = ...) -> Optional[Message]: ...
|
||||
def iter_attachments(self) -> Iterator[Message]: ...
|
||||
@@ -148,3 +123,8 @@ class MIMEPart:
|
||||
else:
|
||||
@property
|
||||
def is_attachment(self) -> bool: ...
|
||||
|
||||
class EmailMessage(MIMEPart):
|
||||
def set_content(self, *args: Any,
|
||||
content_manager: Optional[ContentManager] = ...,
|
||||
**kw: Any) -> None: ...
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
from typing import Callable, Optional, TextIO, BinaryIO
|
||||
import email.feedparser
|
||||
from email.message import Message
|
||||
from email.policy import Policy
|
||||
if sys.version_info >= (3, 3):
|
||||
from email.policy import Policy
|
||||
import sys
|
||||
|
||||
FeedParser = email.feedparser.FeedParser
|
||||
@@ -15,7 +16,7 @@ class Parser:
|
||||
policy: Policy = ...) -> None: ...
|
||||
else:
|
||||
# TODO `strict` is positional
|
||||
def __init__(self, # type: ignore
|
||||
def __init__(self,
|
||||
_class: Callable[[], Message] = ..., *,
|
||||
strict: Optional[bool]) -> None: ...
|
||||
def parse(self, fp: TextIO, headersonly: bool = ...) -> Message: ...
|
||||
@@ -27,7 +28,7 @@ class HeaderParser(Parser):
|
||||
policy: Policy = ...) -> None: ...
|
||||
else:
|
||||
# TODO `strict` is positional
|
||||
def __init__(self, # type: ignore
|
||||
def __init__(self,
|
||||
_class: Callable[[], Message] = ..., *,
|
||||
strict: Optional[bool]) -> None: ...
|
||||
def parse(self, fp: TextIO, headersonly: bool = ...) -> Message: ...
|
||||
@@ -40,7 +41,7 @@ if sys.version_info >= (3, 3):
|
||||
policy: Policy = ...) -> None: ...
|
||||
else:
|
||||
# TODO `strict` is positional
|
||||
def __init__(self, # type: ignore
|
||||
def __init__(self,
|
||||
_class: Callable[[], Message] = ..., *,
|
||||
strict: Optional[bool]) -> None: ...
|
||||
def parse(self, fp: BinaryIO, headersonly: bool = ...) -> Message: ...
|
||||
@@ -53,7 +54,7 @@ if sys.version_info >= (3, 2):
|
||||
policy: Policy = ...) -> None: ...
|
||||
else:
|
||||
# TODO `strict` is positional
|
||||
def __init__(self, # type: ignore
|
||||
def __init__(self,
|
||||
_class: Callable[[], Message] = ..., *,
|
||||
strict: Optional[bool]) -> None: ...
|
||||
def parse(self, fp: BinaryIO, headersonly: bool = ...) -> Message: ...
|
||||
|
||||
@@ -5,7 +5,8 @@ import sys
|
||||
from email.message import Message
|
||||
from email.errors import MessageDefect
|
||||
from email.header import Header
|
||||
from email.contentmanager import ContentManager
|
||||
if sys.version_info >= (3, 4):
|
||||
from email.contentmanager import ContentManager
|
||||
from abc import abstractmethod
|
||||
|
||||
if sys.version_info >= (3, 3):
|
||||
|
||||
Reference in New Issue
Block a user