diff --git a/python_http_client/__init__.py b/python_http_client/__init__.py index 0d88104..79b74b2 100644 --- a/python_http_client/__init__.py +++ b/python_http_client/__init__.py @@ -19,4 +19,5 @@ dir_path = os.path.dirname(os.path.realpath(__file__)) if os.path.isfile(os.path.join(dir_path, 'VERSION.txt')): - __version__ = open(os.path.join(dir_path, 'VERSION.txt')).read().strip() + with open(os.path.join(dir_path, 'VERSION.txt')) as version_file: + __version__ = version_file.read().strip() diff --git a/setup.py b/setup.py index cab04ab..afa54a6 100755 --- a/setup.py +++ b/setup.py @@ -5,9 +5,10 @@ dir_path = os.path.abspath(os.path.dirname(__file__)) -readme = io.open(os.path.join(dir_path, 'README.rst'), encoding='utf-8').read() -version = io.open(os.path.join(dir_path, 'VERSION.txt'), - encoding='utf-8').read().strip() +with io.open(os.path.join(dir_path, 'README.rst'), encoding='utf-8') as readme_file: + readme = readme_file.read() +with io.open(os.path.join(dir_path, 'VERSION.txt'), encoding='utf-8') as version_file: + version = version_file.read().strip() base_url = 'https://github.com/sendgrid/' copy_file(os.path.join(dir_path, 'VERSION.txt'),