Skip to content

Improve {Readable, WriteableBuffer}Buffer #43

Open
@elpekenin

Description

@elpekenin

Right now, there is code using len() on variables hinted as such types. However, this is not correct with the current implementation of hints due to the lack of Sized.

I believe they should be slightly changed like this, such that the type correctly marks the existence of __len__(self) -> int

ReadableBuffer: TypeAlias = TypeVar(
    "ReadableBuffer",
    Sized,
    bound=Union[
        array.array,
        bytearray,
        bytes,
        memoryview,
        "rgbmatrix.RGBMatrix",
        "ulab.numpy.ndarray",
    ],
)

But im not sure about this syntax, as im not a typing expert, would love some feedback before raising a PR. Thanks in advance :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions