mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-09 05:24:52 +08:00
DefaultDict -> defaultdict, typing.ContextManager -> contextlib.AbstractContextManager (#6351)
This commit is contained in:
@@ -4,9 +4,10 @@ from typing import Any
|
||||
# This is a >=3.7 module, so we conditionally include its source.
|
||||
if sys.version_info >= (3, 7):
|
||||
import os
|
||||
from contextlib import AbstractContextManager
|
||||
from pathlib import Path
|
||||
from types import ModuleType
|
||||
from typing import BinaryIO, ContextManager, Iterator, TextIO, Union
|
||||
from typing import BinaryIO, Iterator, TextIO, Union
|
||||
|
||||
Package = Union[str, ModuleType]
|
||||
Resource = Union[str, os.PathLike[Any]]
|
||||
@@ -14,12 +15,11 @@ if sys.version_info >= (3, 7):
|
||||
def open_text(package: Package, resource: Resource, encoding: str = ..., errors: str = ...) -> TextIO: ...
|
||||
def read_binary(package: Package, resource: Resource) -> bytes: ...
|
||||
def read_text(package: Package, resource: Resource, encoding: str = ..., errors: str = ...) -> str: ...
|
||||
def path(package: Package, resource: Resource) -> ContextManager[Path]: ...
|
||||
def path(package: Package, resource: Resource) -> AbstractContextManager[Path]: ...
|
||||
def is_resource(package: Package, name: str) -> bool: ...
|
||||
def contents(package: Package) -> Iterator[str]: ...
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from contextlib import AbstractContextManager
|
||||
from importlib.abc import Traversable
|
||||
def files(package: Package) -> Traversable: ...
|
||||
def as_file(path: Traversable) -> AbstractContextManager[Path]: ...
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import asynchat
|
||||
import asyncore
|
||||
import socket
|
||||
from typing import Any, DefaultDict, Tuple, Type
|
||||
from collections import defaultdict
|
||||
from typing import Any, Tuple, Type
|
||||
|
||||
_Address = Tuple[str, int] # (host, port)
|
||||
|
||||
@@ -9,7 +10,7 @@ class SMTPChannel(asynchat.async_chat):
|
||||
COMMAND: int
|
||||
DATA: int
|
||||
|
||||
command_size_limits: DefaultDict[str, int]
|
||||
command_size_limits: defaultdict[str, int]
|
||||
smtp_server: SMTPServer
|
||||
conn: socket.socket
|
||||
addr: Any
|
||||
|
||||
@@ -4,13 +4,13 @@ import sys
|
||||
import unittest.result
|
||||
from _typeshed import Self
|
||||
from collections.abc import Set # equivalent to typing.AbstractSet, not builtins.set
|
||||
from contextlib import AbstractContextManager
|
||||
from types import TracebackType
|
||||
from typing import (
|
||||
Any,
|
||||
AnyStr,
|
||||
Callable,
|
||||
Container,
|
||||
ContextManager,
|
||||
Generic,
|
||||
Iterable,
|
||||
Mapping,
|
||||
@@ -61,7 +61,7 @@ class TestCase:
|
||||
def run(self, result: unittest.result.TestResult | None = ...) -> unittest.result.TestResult | None: ...
|
||||
def __call__(self, result: unittest.result.TestResult | None = ...) -> unittest.result.TestResult | None: ...
|
||||
def skipTest(self, reason: Any) -> None: ...
|
||||
def subTest(self, msg: Any = ..., **params: Any) -> ContextManager[None]: ...
|
||||
def subTest(self, msg: Any = ..., **params: Any) -> AbstractContextManager[None]: ...
|
||||
def debug(self) -> None: ...
|
||||
def _addSkip(self, result: unittest.result.TestResult, test_case: TestCase, reason: str) -> None: ...
|
||||
def assertEqual(self, first: Any, second: Any, msg: Any = ...) -> None: ...
|
||||
|
||||
Reference in New Issue
Block a user