mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-08 04:54:47 +08:00
Use PEP 688 (#10225)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import sys
|
||||
from _typeshed import FileDescriptorLike, ReadOnlyBuffer, WriteableBuffer
|
||||
from typing import Any, overload
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Buffer, Literal
|
||||
|
||||
if sys.platform != "win32":
|
||||
FASYNC: int
|
||||
@@ -104,13 +104,19 @@ if sys.platform != "win32":
|
||||
def fcntl(__fd: FileDescriptorLike, __cmd: int, __arg: int = 0) -> int: ...
|
||||
@overload
|
||||
def fcntl(__fd: FileDescriptorLike, __cmd: int, __arg: str | ReadOnlyBuffer) -> bytes: ...
|
||||
# If arg is an int, return int
|
||||
@overload
|
||||
def ioctl(__fd: FileDescriptorLike, __request: int, __arg: int = 0, __mutate_flag: bool = True) -> int: ...
|
||||
# The return type works as follows:
|
||||
# - If arg is a read-write buffer, return int if mutate_flag is True, otherwise bytes
|
||||
# - If arg is a read-only buffer, return bytes (and ignore the value of mutate_flag)
|
||||
# We can't represent that precisely as we can't distinguish between read-write and read-only
|
||||
# buffers, so we add overloads for a few unambiguous cases and use Any for the rest.
|
||||
@overload
|
||||
def ioctl(__fd: FileDescriptorLike, __request: int, __arg: WriteableBuffer, __mutate_flag: Literal[True] = True) -> int: ...
|
||||
def ioctl(__fd: FileDescriptorLike, __request: int, __arg: bytes, __mutate_flag: bool = True) -> bytes: ...
|
||||
@overload
|
||||
def ioctl(__fd: FileDescriptorLike, __request: int, __arg: WriteableBuffer, __mutate_flag: Literal[False]) -> bytes: ...
|
||||
@overload
|
||||
def ioctl(__fd: FileDescriptorLike, __request: int, __arg: ReadOnlyBuffer, __mutate_flag: bool = True) -> bytes: ...
|
||||
def ioctl(__fd: FileDescriptorLike, __request: int, __arg: Buffer, __mutate_flag: bool = True) -> Any: ...
|
||||
def flock(__fd: FileDescriptorLike, __operation: int) -> None: ...
|
||||
def lockf(__fd: FileDescriptorLike, __cmd: int, __len: int = 0, __start: int = 0, __whence: int = 0) -> Any: ...
|
||||
|
||||
Reference in New Issue
Block a user