Skip to content
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

Changed cache_handler.py to utilize Python's Context Management Protocol #991

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

508chris
Copy link

I changed two methods within the CacheHandler class, get_cached_token and save_token_to_cache. Instead of opening and closing files manually, I updated these methods to use Python's "with" statement to keep up with good practice in Python programming.
This will also alleviate any errors that occur before the file is closed which would result in allocated resources.
Using the with statement, it simplifies the code as well as provides more reliability to the code base.

I also added an except clause to the get_cached_token method to handle any json decode errors.

Let me know if you have any questions at all.

… to utilize pythons context management protocol to open and close files, instead of opening and closing manually. More information specified in the pull request.
@508chris
Copy link
Author

updated change log

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.

1 participant