circuitpython_typing

Types needed for type annotation that are not in typing

  • Author(s): Alec Delaney, Dan Halbert, Randy Hudson

circuitpython_typing.Alarm

Classes that implement alarms for sleeping and asynchronous notification. You can use these alarms to wake up from light or deep sleep.

alias of alarm.pin.PinAlarm | alarm.time.TimeAlarm

circuitpython_typing.AudioSample

Classes that implement the audiosample protocol. You can play these back with audioio.AudioOut, audiobusio.I2SOut or audiopwmio.PWMAudioOut.

alias of audiocore.WaveFile | audiocore.RawSample | audiomixer.Mixer | audiomp3.MP3Decoder | synthio.MidiTrack

class circuitpython_typing.BlockDevice(*args, **kwargs)

Protocol for block device objects to enable a device to support CircuitPython filesystems. Classes which implement this protocol include storage.VfsFat.

readblocks(start_block: int, buf: array | bytearray | memoryview | rgbmatrix.RGBMatrix | ulab.numpy.ndarray) None

Read aligned, multiples of blocks. Starting at the block given by the index start_block, read blocks from the device into buf. The number of blocks to read is given by the length of buf, which will be a multiple of the block size.

writeblocks(start_block: int, buf: array | bytearray | bytes | memoryview | rgbmatrix.RGBMatrix | ulab.numpy.ndarray) None

Write aligned, multiples of blocks, and require that the blocks that are written to be first erased (if necessary) by this method. Starting at the block given by the index start_block, write blocks from buf to the device. The number of blocks to write is given by the length of buf, which will be a multiple of the block size.

class circuitpython_typing.ByteStream(*args, **kwargs)

Protocol for basic I/O operations on a byte stream. Classes which implement this protocol include * io.BytesIO * io.FileIO (for a file open in binary mode) * busio.UART * usb_cdc.Serial

read(count: int | None = None, /) bytes | None

Read count bytes from the stream. If count bytes are not immediately available, or if the parameter is not specified in the call, the outcome is implementation-dependent.

write(buf: array | bytearray | bytes | memoryview | rgbmatrix.RGBMatrix | ulab.numpy.ndarray, /) int | None

Write the bytes in buf to the stream.

circuitpython_typing.FrameBuffer: TypeAlias = ForwardRef('rgbmatrix.RGBMatrix')

Classes that implement the framebuffer protocol.

circuitpython_typing.ReadableBuffer

Classes that implement the readable buffer protocol.

alias of array | bytearray | bytes | memoryview | rgbmatrix.RGBMatrix | ulab.numpy.ndarray

circuitpython_typing.WriteableBuffer

Classes that implement the writeable buffer protocol.

alias of array | bytearray | memoryview | rgbmatrix.RGBMatrix | ulab.numpy.ndarray

circuitpython_typing.socket

Type annotation definitions for sockets. Used for adafruit_requests and similar libraries.

  • Author(s): Kevin Conley

class circuitpython_typing.socket.CircuitPythonSocketType(*args, **kwargs)

Describes the structure every modern CircuitPython socket type must have.

class circuitpython_typing.socket.CommonCircuitPythonSocketType(*args, **kwargs)

Describes the common structure every CircuitPython socket type must have.

connect(address: Tuple[str, int], conntype: int | None = Ellipsis) None

Connect to a remote socket at the provided (host, port) address. The conntype kwarg optionally may indicate SSL or not, depending on the underlying interface.

class circuitpython_typing.socket.CommonSocketType(*args, **kwargs)

Describes the common structure every socket type must have.

close() None

Close the socket.

send(data: bytes, flags: int = Ellipsis) None

Send data to the socket. The meaning of the optional flags kwarg is implementation-specific.

settimeout(value: float | None) None

Set a timeout on blocking socket operations.

class circuitpython_typing.socket.InterfaceType(*args, **kwargs)

Describes the structure every interface type must have.

property TLS_MODE: int

Constant representing that a socket’s connection mode is TLS.

class circuitpython_typing.socket.LegacyCircuitPythonSocketType(*args, **kwargs)

Describes the structure a legacy CircuitPython socket type must have.

recv(bufsize: int = Ellipsis) bytes

Receive data from the socket. The return value is a bytes object representing the data received. The maximum amount of data to be received at once is specified by bufsize.

circuitpython_typing.socket.SocketpoolModuleType

alias of ModuleType

class circuitpython_typing.socket.StandardPythonSocketType(*args, **kwargs)

Describes the structure every standard Python socket type must have.

connect(address: Tuple[Any, ...] | str | bytes) None

Connect to a remote socket at the provided address.

class circuitpython_typing.socket.SupportsRecvInto(*args, **kwargs)

Describes a type that possesses a socket recv_into() method.

recv_into(buffer: bytearray, nbytes: int = Ellipsis, flags: int = Ellipsis) int

Receive up to nbytes bytes from the socket, storing the data into the provided buffer. If nbytes is not specified (or 0), receive up to the size available in the given buffer. The meaning of the optional flags kwarg is implementation-specific. Returns the number of bytes received.

class circuitpython_typing.socket.SupportsRecvWithFlags(*args, **kwargs)

Describes a type that posseses a socket recv() method supporting the flags kwarg.

recv(bufsize: int = Ellipsis, flags: int = Ellipsis) bytes

Receive data from the socket. The return value is a bytes object representing the data received. The maximum amount of data to be received at once is specified by bufsize. The meaning of the optional flags kwarg is implementation-specific.