Skip to content

added ByteStream protocol #2

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

Merged
merged 2 commits into from
Feb 22, 2022
Merged

Conversation

rimwolf-redux
Copy link
Contributor

Adds ByteStream protocol to circuitpython_typing. Partially addresses #6050 by defining a suitable type for annotating in msgpack.pack and msgpack.unpack.

Copy link
Contributor

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I wonder if we want separate Read and Write ByteStreams, for cases where the stream is only read or written to. @prplz suggested that in adafruit/circuitpython#6050? Would that make sense, do you think, to be more precise?

We seem to be ahead of the kinds of things regular Python has added already to their typing protocols.

@rimwolf-redux
Copy link
Contributor Author

If there's a use case for it, it would be useful to have Readable- and WriteableByteStream. I'll go ahead and make another commit for that.

My only concern is whether we still need the combo ByteStream as a single type annotation; I'm not familiar with other places byte streams are use in CircPy. The obvious thing to do is have a class ByteStream(ReadableByteSteam, WriteableByteStream) definition. But sometimes it seems that readthedocs isn't good about showing either superclasses or inherited methods; I know I've had to guess where to find a description of a method that I know an object has.

Copy link
Contributor

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do this for now, and do more specialized streams on demand, as we need them. It's very easy to add to this library. Thanks!

@dhalbert dhalbert merged commit 85e90eb into adafruit:main Feb 22, 2022
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

Successfully merging this pull request may close these issues.

2 participants