-
Notifications
You must be signed in to change notification settings - Fork 28
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
Turned SDK APIs into context manager #283
Conversation
Signed-off-by: aadityasinha-dotcom <[email protected]>
Signed-off-by: aadityasinha-dotcom <[email protected]>
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.
Thanks @aadityasinha-dotcom, left a comment 🙂
Could you please also update the examples in SDK readmes to use with
statement? For example, in the z/OS Console readme:
from zowe.core_for_zowe_sdk import ProfileManager
from zowe.zos_console_for_zowe_sdk import Console
profile = ProfileManager().load(profile_name="zosmf")
with Console(profile) as console_info:
print(console_info.issue_command(command="D IPLINFO", console="EMCS"))
Co-authored-by: Timothy Johnson <[email protected]> Signed-off-by: Aaditya Sinha <[email protected]>
def __enter__(self): | ||
return self | ||
|
||
def __exit__(self, exc_type, exception, traceback): |
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.
Will there be any use of exc_type, exception, traceback
?
I am curious 🤔
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.
I think these parameters could be used to do exception handling inside the __exit__
function 😋
https://realpython.com/python-with-statement/#handling-exceptions-in-a-context-manager
In our case we always want to clean up the request handler and session object, regardless of whether an error has been raised, so I don't think we need to use them at all.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #283 +/- ##
==========================================
- Coverage 89.32% 89.27% -0.05%
==========================================
Files 53 53
Lines 2529 2536 +7
==========================================
+ Hits 2259 2264 +5
- Misses 270 272 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Signed-off-by: aadityasinha-dotcom <[email protected]>
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.
LGTM, thanks @aadityasinha-dotcom!
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.
LGTM, thanks @aadityasinha-dotcom!
What It Does
Resolves #145
How to Test
Review Checklist
I certify that I have:
Additional Comments