From a67b697c49c24bb5691db1b5759f9d3c8fbd0d3e Mon Sep 17 00:00:00 2001 From: Content Bot Date: Wed, 19 Jun 2024 13:57:49 +0000 Subject: [PATCH 1/5] ML: apply UP015 --- .../DBotPredictOutOfTheBoxV2/DBotPredictOutOfTheBoxV2.py | 2 +- Packs/ML/Scripts/ExportMLModel/ExportMLModel_test.py | 2 +- Packs/ML/Scripts/ImportMLModel/ImportMLModel.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Packs/ML/Scripts/DBotPredictOutOfTheBoxV2/DBotPredictOutOfTheBoxV2.py b/Packs/ML/Scripts/DBotPredictOutOfTheBoxV2/DBotPredictOutOfTheBoxV2.py index 8bc85fac9f72..0e7d45042808 100644 --- a/Packs/ML/Scripts/DBotPredictOutOfTheBoxV2/DBotPredictOutOfTheBoxV2.py +++ b/Packs/ML/Scripts/DBotPredictOutOfTheBoxV2/DBotPredictOutOfTheBoxV2.py @@ -37,7 +37,7 @@ def load_oob_model(): if is_error(res): return_error(get_error(res)) - with open(EVALUATION_PATH, 'r') as json_file: + with open(EVALUATION_PATH) as json_file: data = json.load(json_file) y_test = data['YTrue'] y_pred = data['YPred'] diff --git a/Packs/ML/Scripts/ExportMLModel/ExportMLModel_test.py b/Packs/ML/Scripts/ExportMLModel/ExportMLModel_test.py index 4f2a3b4d960c..6b34864b3f7a 100644 --- a/Packs/ML/Scripts/ExportMLModel/ExportMLModel_test.py +++ b/Packs/ML/Scripts/ExportMLModel/ExportMLModel_test.py @@ -19,7 +19,7 @@ def execute_command(command, args): def results(result): file_id = result['FileID'] - with open(demisto.investigation()['id'] + '_' + file_id, 'r') as f: + with open(demisto.investigation()['id'] + '_' + file_id) as f: file_data_str = f.read() file_data = json.loads(file_data_str) assert (all(x in file_data for x in dummy_data) and all(x in dummy_data for x in file_data)) diff --git a/Packs/ML/Scripts/ImportMLModel/ImportMLModel.py b/Packs/ML/Scripts/ImportMLModel/ImportMLModel.py index 08d70d4c5968..8201927250d2 100644 --- a/Packs/ML/Scripts/ImportMLModel/ImportMLModel.py +++ b/Packs/ML/Scripts/ImportMLModel/ImportMLModel.py @@ -11,7 +11,7 @@ def read_file_content(input_entry_or_string): if not res: return_error("Entry {} not found".format(input_entry_or_string)) file_path = res['path'] - with open(file_path, 'r') as f: + with open(file_path) as f: file_content = f.read() return file_content From 96628366c3ebfc399dc0a9a6be85b0096fe65b2b Mon Sep 17 00:00:00 2001 From: Content Bot Date: Wed, 19 Jun 2024 13:57:51 +0000 Subject: [PATCH 2/5] MalwareInvestigationAndResponse: apply UP015 --- .../ReadProcessesFileXDR/ReadProcessesFileXDR_test.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Packs/MalwareInvestigationAndResponse/Scripts/ReadProcessesFileXDR/ReadProcessesFileXDR_test.py b/Packs/MalwareInvestigationAndResponse/Scripts/ReadProcessesFileXDR/ReadProcessesFileXDR_test.py index a364f3028f4f..ad877ab3c367 100644 --- a/Packs/MalwareInvestigationAndResponse/Scripts/ReadProcessesFileXDR/ReadProcessesFileXDR_test.py +++ b/Packs/MalwareInvestigationAndResponse/Scripts/ReadProcessesFileXDR/ReadProcessesFileXDR_test.py @@ -15,11 +15,11 @@ def test_entries_to_markdown(_return_value, res): - parse the _return_value string entries and return them in a markdown format """ from ReadProcessesFileXDR import entries_to_markdown - with open(_return_value, 'r') as process_list_from_xdr: + with open(_return_value) as process_list_from_xdr: # Reading from json file proces_list = json.load(process_list_from_xdr) entries_as_md = entries_to_markdown(proces_list) - with open(res, 'r') as res_md: + with open(res) as res_md: res_md = res_md.read() assert res_md == entries_as_md @@ -42,7 +42,7 @@ def test_find_last_process_list_script(script_results, res): with open('test_data/script_results.json') as f: script_results = json.load(f) script_result = find_last_process_list_script(script_results) - with open('test_data/filter_script_results.json', 'r') as res: + with open('test_data/filter_script_results.json') as res: filter_res = json.load(res) assert filter_res == script_result From dba04ee5e7017ab120a4c92d08997e05b2e82074 Mon Sep 17 00:00:00 2001 From: Content Bot Date: Wed, 19 Jun 2024 13:57:53 +0000 Subject: [PATCH 3/5] Netmiko: apply UP015 --- Packs/Netmiko/Integrations/Netmiko/Netmiko_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Packs/Netmiko/Integrations/Netmiko/Netmiko_test.py b/Packs/Netmiko/Integrations/Netmiko/Netmiko_test.py index 948d9b61b409..789406b3e390 100644 --- a/Packs/Netmiko/Integrations/Netmiko/Netmiko_test.py +++ b/Packs/Netmiko/Integrations/Netmiko/Netmiko_test.py @@ -3,7 +3,7 @@ def get_test_data(): - with open('test_data/test_data.json', 'r') as f: + with open('test_data/test_data.json') as f: return json.loads(f.read()) From 1234e7a1cc478d7c9e974604677312c1adcdafeb Mon Sep 17 00:00:00 2001 From: Content Bot Date: Wed, 19 Jun 2024 13:57:55 +0000 Subject: [PATCH 4/5] PcapAnalysis: apply UP015 --- Packs/PcapAnalysis/Scripts/PcapConvert/PcapConvert_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Packs/PcapAnalysis/Scripts/PcapConvert/PcapConvert_test.py b/Packs/PcapAnalysis/Scripts/PcapConvert/PcapConvert_test.py index 6fef00ef2935..b1c2a899aad8 100644 --- a/Packs/PcapAnalysis/Scripts/PcapConvert/PcapConvert_test.py +++ b/Packs/PcapAnalysis/Scripts/PcapConvert/PcapConvert_test.py @@ -15,7 +15,7 @@ def test_main(mocker): """ from PcapConvert import main - with open('./test_data/test-1.json', 'r') as f: + with open('./test_data/test-1.json') as f: test_list = json.load(f) for t in test_list: From c381c5f8a70caf0b175ad1ae1a23a6bf608b973b Mon Sep 17 00:00:00 2001 From: Content Bot Date: Wed, 19 Jun 2024 13:57:57 +0000 Subject: [PATCH 5/5] Phishing: apply UP015 --- .../Scripts/DeleteReportedEmail/DeleteReportedEmail_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Packs/Phishing/Scripts/DeleteReportedEmail/DeleteReportedEmail_test.py b/Packs/Phishing/Scripts/DeleteReportedEmail/DeleteReportedEmail_test.py index 6644fa131f82..8cb2eb7ab459 100644 --- a/Packs/Phishing/Scripts/DeleteReportedEmail/DeleteReportedEmail_test.py +++ b/Packs/Phishing/Scripts/DeleteReportedEmail/DeleteReportedEmail_test.py @@ -69,7 +69,7 @@ def test_get_deletion_args(integration_name): Then: return the suitable deletion args """ - with open(os.path.join(TEST_DATA, f'{integration_name}{SEARCH_RESPONSE_SUFFIX}'), 'r') as file: + with open(os.path.join(TEST_DATA, f'{integration_name}{SEARCH_RESPONSE_SUFFIX}')) as file: search_results = json.load(file) assert EXPECTED_DELETION_ARGS_RESULTS[integration_name] == ARGS_FUNC[integration_name](search_results, SEARCH_ARGS) @@ -84,7 +84,7 @@ def test_delete_email(mocker, integration_name): Then: delete the email """ - with open(os.path.join(TEST_DATA, f'{integration_name}{SEARCH_RESPONSE_SUFFIX}'), 'r') as file: + with open(os.path.join(TEST_DATA, f'{integration_name}{SEARCH_RESPONSE_SUFFIX}')) as file: search_results = json.load(file) mocker.patch.object(DeleteReportedEmail, 'execute_command', return_value=search_results) assert delete_email(SEARCH_ARGS, 'func', ARGS_FUNC[integration_name], 'func', lambda x: False) == 'Success'