[PR #11341/5b5f7e9e backport][stable-12] batch 1 - update Python idiom to 3.7 using pyupgrade (#11349)

batch 1 - update Python idiom to 3.7 using pyupgrade (#11341)

* batch 1 - update Python idiom to 3.7 using pyupgrade

* add changelog frag

* add changelog frag

(cherry picked from commit 5b5f7e9e64)

Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
patchback[bot]
2025-12-30 16:47:11 +01:00
committed by GitHub
parent 41f815be57
commit 2d07481e64
19 changed files with 48 additions and 29 deletions

View File

@@ -210,9 +210,9 @@ class InventoryModule(BaseInventoryPlugin):
Returns:
dict(json_data): json data"""
try:
with open(path, "r") as json_file:
with open(path) as json_file:
return json.load(json_file)
except (IOError, json.decoder.JSONDecodeError) as err:
except (OSError, json.decoder.JSONDecodeError) as err:
raise AnsibleParserError(f"Could not load the test data from {to_native(path)}: {err}") from err
def save_json_data(self, path, file_name=None):
@@ -242,7 +242,7 @@ class InventoryModule(BaseInventoryPlugin):
cwd = os.path.abspath(os.path.dirname(__file__))
with open(os.path.abspath(os.path.join(cwd, *path)), "w") as json_file:
json.dump(self.data, json_file)
except IOError as err:
except OSError as err:
raise AnsibleParserError(f"Could not save data: {err}") from err
def verify_file(self, path):