-
Notifications
You must be signed in to change notification settings - Fork 139
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
feat: support io.StringIO
as fp
param to disnake.File
#767
base: master
Are you sure you want to change the base?
Conversation
Might be worth considering replacing the union of |
I don't know about this - as pyright already complains, this breaks a few places that expect For the |
So you suggest not to change the typing, and instead have the user do something like |
I can't think of many scenarios where one can get a string stream but not a bytes stream, in the simplest case it's a matter of changing |
My primary use case is creating an in-memory text file from a string with |
Just commenting for the record, I'd also plus 1 this feature as something I use within bots to save arbitrary writes to disk |
io.TextIOBase
as supported fp for disnake.File
io.StringIO
as supported file-like object to disnake.File
@shiftinv I forgot about this PR; how about we special-case |
Since this topic came up again yesterday, I looked into this more; somehow missed the last comment here, sorry.
Yeah, this seems like the better option. aiohttp ends up doing almost the same thing internally if you pass |
Do we have anything further on this PR? Seems like a usable resolution is fairly close |
io.StringIO
as supported file-like object to disnake.File
io.StringIO
as fp
param to disnake.File
317af88
to
eb6551d
Compare
Summary
Adds support for passing
io.StringIO
todisnake.File
Closes #765
Checklist
task lint
task pyright