diff --git a/hooks/gen_docs/gen_docs_contributing.py b/hooks/gen_docs/gen_docs_contributing.py index 4d8767e90..7970b192b 100644 --- a/hooks/gen_docs/gen_docs_contributing.py +++ b/hooks/gen_docs/gen_docs_contributing.py @@ -1,4 +1,4 @@ -"""Copies ``CONTROBUTING.md`` from root to the docs""" +"""Copies ``CONTROBUTING.md`` from root to the docs.""" import shutil from pathlib import Path from tempfile import TemporaryFile @@ -10,10 +10,12 @@ # Copy `CONTRIBUTING.md` into the equivalent file in the docs, # adding a comment at the top which notes that the file is generated -with TemporaryFile() as file_header: +with ( + TemporaryFile() as file_header, + DEST.open("w+b") as file_dest, + SOURCE.open("rb") as file_source, +): file_header.write(HEADER) file_header.seek(0) - with DEST.open("w+b") as file_dest: - with SOURCE.open("rb") as file_source: - shutil.copyfileobj(file_header, file_dest) - shutil.copyfileobj(file_source, file_dest) + shutil.copyfileobj(file_header, file_dest) + shutil.copyfileobj(file_source, file_dest)