Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ruff UP015 (7) #34956

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
2 changes: 1 addition & 1 deletion Packs/ML/Scripts/ExportMLModel/ExportMLModel_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion Packs/ML/Scripts/ImportMLModel/ImportMLModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion Packs/Netmiko/Integrations/Netmiko/Netmiko_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())


Expand Down
2 changes: 1 addition & 1 deletion Packs/PcapAnalysis/Scripts/PcapConvert/PcapConvert_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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'
Expand Down
Loading