From 6d215888e94c1820fd7f9d64b98699547e1dd425 Mon Sep 17 00:00:00 2001 From: "pixeebot[bot]" <104101892+pixeebot[bot]@users.noreply.github.com> Date: Tue, 12 Mar 2024 03:14:28 +0000 Subject: [PATCH] Use Assignment Expression (Walrus) In Conditional --- delete_closed_or_merged_pr_forks.py | 3 +-- jhipster_security_fix.py | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/delete_closed_or_merged_pr_forks.py b/delete_closed_or_merged_pr_forks.py index 2ab2dbf8..76f75694 100644 --- a/delete_closed_or_merged_pr_forks.py +++ b/delete_closed_or_merged_pr_forks.py @@ -38,8 +38,7 @@ def read_results_data(json_file_name: str): data = read_results_data(file) project_name: str = data['project_name'] print(f'loading project: {project_name}') - pull_url = data['pull_request'] - if pull_url == '': + if (pull_url := data['pull_request']) == '': continue diff --git a/jhipster_security_fix.py b/jhipster_security_fix.py index 0b16ae28..31639d0b 100644 --- a/jhipster_security_fix.py +++ b/jhipster_security_fix.py @@ -70,8 +70,7 @@ async def do_fix_vulnerable_file(self, project_name: str, file: str, expected_fi async with aiofiles.open(file, newline='') as vulnerableFile: contents: str = await vulnerableFile.read() - new_contents = await self.do_fix_file_contents(contents) - if new_contents == contents: + if (new_contents := await self.do_fix_file_contents(contents)) == contents: return 0 async with aiofiles.open(file, 'w', newline='') as vulnerableFile: