mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 20:54:28 +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,5 +1,6 @@
|
||||
from typing import Any, Union, IO
|
||||
import io
|
||||
from _types import FileDescriptorLike
|
||||
|
||||
FASYNC: int
|
||||
FD_CLOEXEC: int
|
||||
@@ -72,16 +73,14 @@ LOCK_SH: int
|
||||
LOCK_UN: int
|
||||
LOCK_WRITE: int
|
||||
|
||||
_ANYFILE = Union[int, IO]
|
||||
|
||||
# TODO All these return either int or bytes depending on the value of
|
||||
# cmd (not on the type of arg).
|
||||
def fcntl(fd: _ANYFILE, op: int, arg: Union[int, bytes] = ...) -> Any: ...
|
||||
def fcntl(fd: FileDescriptorLike, op: int, arg: Union[int, bytes] = ...) -> Any: ...
|
||||
|
||||
# TODO: arg: int or read-only buffer interface or read-write buffer interface
|
||||
def ioctl(fd: _ANYFILE, op: int, arg: Union[int, bytes] = ...,
|
||||
def ioctl(fd: FileDescriptorLike, op: int, arg: Union[int, bytes] = ...,
|
||||
mutate_flag: bool = ...) -> Any: ...
|
||||
|
||||
def flock(fd: _ANYFILE, op: int) -> None: ...
|
||||
def lockf(fd: _ANYFILE, op: int, length: int = ..., start: int = ...,
|
||||
def flock(fd: FileDescriptorLike, op: int) -> None: ...
|
||||
def lockf(fd: FileDescriptorLike, op: int, length: int = ..., start: int = ...,
|
||||
whence: int = ...) -> Any: ...
|
||||
|
||||
Reference in New Issue
Block a user