Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve {Readable, WriteableBuffer}Buffer #43

Open
elpekenin opened this issue Aug 20, 2024 · 0 comments
Open

Improve {Readable, WriteableBuffer}Buffer #43

elpekenin opened this issue Aug 20, 2024 · 0 comments

Comments

@elpekenin
Copy link

elpekenin commented Aug 20, 2024

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant