uio: Update style.

Also fix compatibility information.
This commit is contained in:
Laurens Valk
2022-11-29 20:23:23 +01:00
parent 56ab509630
commit 71ce165a46
2 changed files with 24 additions and 16 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
.. pybricks-requirements:: stm32-extra
:mod:`uio` -- Input/output streams
==================================
.. note:: This module is not available on the BOOST Move Hub.
.. automodule:: uio
+22 -14
View File
@@ -1,18 +1,17 @@
# SPDX-License-Identifier: MIT
# Copyright (c) 2021 The Pybricks Authors
# Copyright (c) 2022 The Pybricks Authors
#
# Portions of documentation copied from:
# https://raw.githubusercontent.com/micropython/micropython/1e6d18c915ccea0b6a19ffec9710d33dd7e5f866/docs/library/uio.rst
# Copyright (c) 2014-2021, Damien P. George, Paul Sokolovsky, and contributors
"""
This module contains additional types of ``stream`` (file-like) objects
and helper functions.
This module contains ``stream`` objects that behave like files.
"""
# TODO: open() is not implemented on Powered Up hubs
from typing import overload
from typing import overload, Union
# TODO: MicroPython streams implement '__enter__', '__exit__', 'close', 'read',
# 'readinto', 'readline', 'write', 'flush', 'getvalue', 'seek', 'tell'
@@ -25,7 +24,7 @@ class BytesIO:
...
@overload
def __init__(self, initial_bytes: bytes) -> None:
def __init__(self, data: Union[bytes, bytearray]) -> None:
...
@overload
@@ -34,11 +33,16 @@ class BytesIO:
def __init__(self, *args) -> None:
"""
BytesIO()
BytesIO(data)
BytesIO(alloc_size)
A binary stream using an in-memory bytes buffer.
Args:
initial_bytes: Optional bytes-like object that contains initial data.
alloc_size: Optional number of preallocated bytes.
Arguments:
data (bytes or bytearray): Optional bytes-like object
that contains initial data.
alloc_size (int): Optional number of preallocated bytes.
"""
@@ -48,7 +52,7 @@ class StringIO:
...
@overload
def __init__(self, initial_value: str) -> None:
def __init__(self, string: str) -> None:
...
@overload
@@ -57,16 +61,20 @@ class StringIO:
def __init__(self, *args) -> None:
"""
A binary stream using an in-memory string buffer.
StringIO()
StringIO(string)
StringIO(alloc_size)
Args:
initial_value: Optional string object that contains initial data.
alloc_size: Optional number of preallocated bytes.
A stream using an in-memory string buffer.
Arguments:
string (str): Optional string with initial data.
alloc_size (int): Optional number of preallocated bytes.
"""
class FileIO:
"""
This is type of a file open in binary mode, e.g. using ``open(name, 'rb')``.
This type represents a file opened in binary mode with ``open(name, 'rb')``.
You should not instantiate this class directly.
"""