mirror of
https://github.com/ansible-collections/community.docker.git
synced 2026-04-09 19:45:22 +00:00
Address consider-using-with.
This commit is contained in:
parent
40c240ac2b
commit
ecb2d8b01e
@ -379,7 +379,6 @@ disable=raw-checker-failed,
|
||||
wrong-import-order,
|
||||
wrong-import-position,
|
||||
# To clean up:
|
||||
consider-using-with,
|
||||
fixme,
|
||||
import-error, # TODO figure out why pylint cannot find the module
|
||||
no-name-in-module, # TODO figure out why pylint cannot find the module
|
||||
|
||||
@ -525,6 +525,7 @@ class Connection(ConnectionBase):
|
||||
)
|
||||
args = [to_bytes(i, errors="surrogate_or_strict") for i in args]
|
||||
try:
|
||||
# pylint: disable-next=consider-using-with
|
||||
p = subprocess.Popen(
|
||||
args, stdin=in_file, stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
||||
)
|
||||
@ -587,6 +588,7 @@ class Connection(ConnectionBase):
|
||||
to_bytes(actual_out_path, errors="surrogate_or_strict"), "wb"
|
||||
) as out_file:
|
||||
try:
|
||||
# pylint: disable-next=consider-using-with
|
||||
pp = subprocess.Popen(
|
||||
args,
|
||||
stdin=subprocess.PIPE,
|
||||
|
||||
@ -97,8 +97,10 @@ def create_archive(
|
||||
) -> t.IO[bytes]:
|
||||
extra_files = extra_files or []
|
||||
if not fileobj:
|
||||
# pylint: disable-next=consider-using-with
|
||||
fileobj = tempfile.NamedTemporaryFile()
|
||||
tarf = tarfile.open(mode="w:gz" if gzip else "w", fileobj=fileobj)
|
||||
|
||||
with tarfile.open(mode="w:gz" if gzip else "w", fileobj=fileobj) as tarf:
|
||||
if files is None:
|
||||
files = build_file_list(root)
|
||||
extra_names = set(e[0] for e in extra_files)
|
||||
@ -139,7 +141,6 @@ def create_archive(
|
||||
info.size = len(contents_encoded)
|
||||
tarf.addfile(info, io.BytesIO(contents_encoded))
|
||||
|
||||
tarf.close()
|
||||
fileobj.seek(0)
|
||||
return fileobj
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user