mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-08 04:54:47 +08:00
Unify file descriptor definitions (#3584)
The _types module can house any common type defintions used throughout the rest of typeshed to keep defintions in sync. First candidate is file descriptors where anything with `fileno()` method is accepted. There were several different implementations in various files that can be unified.
This commit is contained in:
committed by
Rebecca Chen
parent
1651348a08
commit
955e9c7da4
@@ -1,4 +1,3 @@
|
||||
import selectors
|
||||
from socket import socket, _Address, _RetAddress
|
||||
import ssl
|
||||
import sys
|
||||
@@ -9,6 +8,7 @@ from asyncio.events import AbstractEventLoop, AbstractServer, Handle, TimerHandl
|
||||
from asyncio.protocols import BaseProtocol
|
||||
from asyncio.tasks import Task
|
||||
from asyncio.transports import BaseTransport
|
||||
from _types import FileDescriptorLike
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
from contextvars import Context
|
||||
@@ -183,10 +183,10 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta):
|
||||
async def subprocess_exec(self, protocol_factory: _ProtocolFactory, *args: Any, stdin: Any = ...,
|
||||
stdout: Any = ..., stderr: Any = ...,
|
||||
**kwargs: Any) -> _TransProtPair: ...
|
||||
def add_reader(self, fd: selectors._FileObject, callback: Callable[..., Any], *args: Any) -> None: ...
|
||||
def remove_reader(self, fd: selectors._FileObject) -> None: ...
|
||||
def add_writer(self, fd: selectors._FileObject, callback: Callable[..., Any], *args: Any) -> None: ...
|
||||
def remove_writer(self, fd: selectors._FileObject) -> None: ...
|
||||
def add_reader(self, fd: FileDescriptorLike, callback: Callable[..., Any], *args: Any) -> None: ...
|
||||
def remove_reader(self, fd: FileDescriptorLike) -> None: ...
|
||||
def add_writer(self, fd: FileDescriptorLike, callback: Callable[..., Any], *args: Any) -> None: ...
|
||||
def remove_writer(self, fd: FileDescriptorLike) -> None: ...
|
||||
# Completion based I/O methods returning Futures prior to 3.7
|
||||
if sys.version_info >= (3, 7):
|
||||
async def sock_recv(self, sock: socket, nbytes: int) -> bytes: ...
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import selectors
|
||||
from socket import socket, _Address, _RetAddress
|
||||
import ssl
|
||||
import sys
|
||||
@@ -8,6 +7,7 @@ from asyncio.futures import Future
|
||||
from asyncio.protocols import BaseProtocol
|
||||
from asyncio.tasks import Task
|
||||
from asyncio.transports import BaseTransport
|
||||
from _types import FileDescriptorLike
|
||||
|
||||
_T = TypeVar('_T')
|
||||
_Context = Dict[str, Any]
|
||||
@@ -253,13 +253,13 @@ class AbstractEventLoop(metaclass=ABCMeta):
|
||||
stdout: Any = ..., stderr: Any = ...,
|
||||
**kwargs: Any) -> _TransProtPair: ...
|
||||
@abstractmethod
|
||||
def add_reader(self, fd: selectors._FileObject, callback: Callable[..., Any], *args: Any) -> None: ...
|
||||
def add_reader(self, fd: FileDescriptorLike, callback: Callable[..., Any], *args: Any) -> None: ...
|
||||
@abstractmethod
|
||||
def remove_reader(self, fd: selectors._FileObject) -> None: ...
|
||||
def remove_reader(self, fd: FileDescriptorLike) -> None: ...
|
||||
@abstractmethod
|
||||
def add_writer(self, fd: selectors._FileObject, callback: Callable[..., Any], *args: Any) -> None: ...
|
||||
def add_writer(self, fd: FileDescriptorLike, callback: Callable[..., Any], *args: Any) -> None: ...
|
||||
@abstractmethod
|
||||
def remove_writer(self, fd: selectors._FileObject) -> None: ...
|
||||
def remove_writer(self, fd: FileDescriptorLike) -> None: ...
|
||||
# Completion based I/O methods returning Futures prior to 3.7
|
||||
if sys.version_info >= (3, 7):
|
||||
@abstractmethod
|
||||
|
||||
Reference in New Issue
Block a user