1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-05-02 00:12:54 +00:00

batch 3 - update Python idiom to 3.7 using pyupgrade (#11343)

* batch 3 - update Python idiom to 3.7 using pyupgrade

* add changelog frag

* bring back sanity

* adjust test

* Apply suggestions from code review
This commit is contained in:
Alexei Znamensky 2025-12-31 10:18:52 +13:00 committed by GitHub
parent 543329cecb
commit e8f2b135ba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
26 changed files with 74 additions and 51 deletions

View file

@ -321,7 +321,7 @@ class Archive(metaclass=abc.ABCMeta):
f_out.close()
self.successes.append(path)
self.destination_state = STATE_COMPRESSED
except (IOError, OSError) as e:
except OSError as e:
self.module.fail_json(
path=_to_native(path),
dest=_to_native(self.destination),
@ -506,7 +506,7 @@ class ZipArchive(Archive):
def _get_checksums(self, path):
try:
archive = zipfile.ZipFile(_to_native_ascii(path), "r")
checksums = set((info.filename, info.CRC) for info in archive.infolist())
checksums = {(info.filename, info.CRC) for info in archive.infolist()}
archive.close()
except BadZipFile:
checksums = set()
@ -558,11 +558,11 @@ class TarArchive(Archive):
if self.format == "xz":
with lzma.open(_to_native_ascii(path), "r") as f:
archive = tarfile.open(fileobj=f)
checksums = set((info.name, info.chksum) for info in archive.getmembers())
checksums = {(info.name, info.chksum) for info in archive.getmembers()}
archive.close()
else:
archive = tarfile.open(_to_native_ascii(path), f"r|{self.format}")
checksums = set((info.name, info.chksum) for info in archive.getmembers())
checksums = {(info.name, info.chksum) for info in archive.getmembers()}
archive.close()
except (LZMAError, tarfile.ReadError, tarfile.CompressionError):
try:
@ -575,7 +575,7 @@ class TarArchive(Archive):
if not chunk:
break
checksum = crc32(chunk, checksum)
checksums = set([(b"", checksum)])
checksums = {(b"", checksum)}
f.close()
except Exception:
checksums = set()