Support string input streams#22
Support string input streams#22mattsb42-aws merged 9 commits intoaws:masterfrom ecederstrand:support-string-input
Conversation
|
|
||
| _data_buffer = io.BytesIO() | ||
| _data_buffer.write(b"".join(data.split())) | ||
| _data_buffer = io.BytesIO() if isinstance(data, bytes) else io.StringIO() |
There was a problem hiding this comment.
Method return type annotation needs to change to AnyStr.
There was a problem hiding this comment.
Done. The mypy tests are failing but I'm not sure why - I haven't used mypy previously. It looks like a false positive - maybe mypy is not able to handle the branching logic that handles bytes and str differently?
There was a problem hiding this comment.
The initial problem is just that you need to add an import for AnyStr in the types imports at the top. I'm not sure if the other issues it's running into are just a side effect of missing that or not.
|
I have attempted to fix the mypy test but failed. Adding import of |
mattsb42-aws
left a comment
There was a problem hiding this comment.
I'm going to hack on this a bit before we publish both to see if I can sort out the type annotations and because I have a feeling it might need a couple tweaks to correctly handle unicode in both Python 2 and 3. I want to expand the tests to figure out whether that is an issue, but I don't think it's useful to try and iterate over that through this PR.
I think this is gets us most of the way there, thanks!
Refs #21
Alters the
Base64IO.read()method to support string streams as well as bytes streams.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.