Skip to content

Commit 9a63d4b

Browse files
authored
fix: Remove ResourceWarning on module import (#128)
* Fix ResourceWarning on module import * Fix ResourceWarning in setup.py
1 parent 7820ba1 commit 9a63d4b

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

python_http_client/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@
1919

2020
dir_path = os.path.dirname(os.path.realpath(__file__))
2121
if os.path.isfile(os.path.join(dir_path, 'VERSION.txt')):
22-
__version__ = open(os.path.join(dir_path, 'VERSION.txt')).read().strip()
22+
with open(os.path.join(dir_path, 'VERSION.txt')) as version_file:
23+
__version__ = version_file.read().strip()

setup.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55

66

77
dir_path = os.path.abspath(os.path.dirname(__file__))
8-
readme = io.open(os.path.join(dir_path, 'README.rst'), encoding='utf-8').read()
9-
version = io.open(os.path.join(dir_path, 'VERSION.txt'),
10-
encoding='utf-8').read().strip()
8+
with io.open(os.path.join(dir_path, 'README.rst'), encoding='utf-8') as readme_file:
9+
readme = readme_file.read()
10+
with io.open(os.path.join(dir_path, 'VERSION.txt'), encoding='utf-8') as version_file:
11+
version = version_file.read().strip()
1112
base_url = 'https://github.com/sendgrid/'
1213

1314
copy_file(os.path.join(dir_path, 'VERSION.txt'),

0 commit comments

Comments
 (0)