mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-10 05:51:52 +08:00
Fold remaining custom stdlib *Buffer types into _typeshed. (#6082)
Add ctypes base type to WriteableBuffer. Add a ReadOnlyBuffer type from fcntl. Base ReadableBuffer on WriteableBuffer and ReadOnlyBuffer. Use these types in fcntl and ctypes stubs.
This commit is contained in:
committed by
GitHub
parent
328d09a9a5
commit
4c0dccac0f
@@ -3,6 +3,7 @@
|
||||
# See the README.md file in this directory for more information.
|
||||
|
||||
import array
|
||||
import ctypes
|
||||
import mmap
|
||||
import sys
|
||||
from os import PathLike
|
||||
@@ -167,8 +168,13 @@ class SupportsNoArgReadline(Protocol[_T_co]):
|
||||
class SupportsWrite(Protocol[_T_contra]):
|
||||
def write(self, __s: _T_contra) -> Any: ...
|
||||
|
||||
ReadableBuffer = Union[bytes, bytearray, memoryview, array.array[Any], mmap.mmap] # stable
|
||||
WriteableBuffer = Union[bytearray, memoryview, array.array[Any], mmap.mmap] # stable
|
||||
ReadOnlyBuffer = bytes # stable
|
||||
# Anything that implements the read-write buffer interface.
|
||||
# The buffer interface is defined purely on the C level, so we cannot define a normal Protocol
|
||||
# for it. Instead we have to list the most common stdlib buffer classes in a Union.
|
||||
WriteableBuffer = Union[bytearray, memoryview, array.array[Any], mmap.mmap, ctypes._CData] # stable
|
||||
# Same as _WriteableBuffer, but also includes read-only buffer types (like bytes).
|
||||
ReadableBuffer = Union[ReadOnlyBuffer, WriteableBuffer] # stable
|
||||
|
||||
# stable
|
||||
if sys.version_info >= (3, 10):
|
||||
|
||||
Reference in New Issue
Block a user