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(file): add context manager to File #998
Conversation
Add Context Manager to `nextcord.File`
feat: add context manager for `File` Add a context manager to `nextcord.File`. Also change `force_close` to be optional default to None so that we can set `force_close` to True when using context manager if `False` was not provided to init.
feat: add context manager for `File` Add a context manager to `nextcord.File`. Also change `force_close` to be optional default to None so that we can set `force_close` to True when using context manager if `False` was not provided to init.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice first PR, thanks for the explanation!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did not need to make that approved.
Co-authored-by: Emre Terzioglu <50607143+EmreTech@users.noreply.github.com> Co-authored-by: Oliver Wilkes <oliverwilkes2006@icloud.com>
Co-authored-by: Emre Terzioglu <50607143+EmreTech@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not tested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't tested but it LGTM!
File
Summary
Add a context manager to
nextcord.File
. This will automatically callclose()
on the file when the context manager exits scope.Also change
force_close
to be optional default to None so that we can setforce_close
to True when using context manager ifFalse
was not provided to init.Old Method
New Method (w/ Context Manager)
Checklist
task pyright
and fixed the relevant issues.