File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -155,10 +155,11 @@ There are a few techniques to store the version in your project code without dup
155155 from `pip setup.py <https://github.com/pypa/pip/blob/1.5.6/setup.py#L33 >`_)::
156156
157157 def read(*names, **kwargs):
158- return io.open(
158+ with io.open(
159159 os.path.join(os.path.dirname(__file__), *names),
160160 encoding=kwargs.get("encoding", "utf8")
161- ).read()
161+ ) as fp:
162+ return fp.read()
162163
163164 def find_version(*file_paths):
164165 version_file = read(*file_paths)
@@ -213,8 +214,8 @@ There are a few techniques to store the version in your project code without dup
213214
214215 ::
215216
216- version_file = open(os.path.join(mypackage_root_dir, 'VERSION'))
217- version = version_file.read().strip()
217+ with open(os.path.join(mypackage_root_dir, 'VERSION')) as version_file:
218+ version = version_file.read().strip()
218219
219220 An advantage with this technique is that it's not specific to Python. Any
220221 tool can read the version.
You can’t perform that action at this time.
0 commit comments