Skip to content
Merged
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
1 change: 0 additions & 1 deletion .ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ select = [
ignore = [
"E501", # line too long

"UP015", # redundant-open-modes
"UP031", # printf-string-formatting
"UP035", # deprecated-import
"B006", # mutable-argument-default
Expand Down
2 changes: 1 addition & 1 deletion src/powerapi/cli/config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ def parse_config_dict(self, file_name: str) -> dict:
Return a configuration dict that has all the arguments' names in the long form.
If an argument does not exist, a UnknownArgException is raised
"""
with open(file_name, 'r', encoding='utf-8') as config_file:
with open(file_name, encoding='utf-8') as config_file:
conf = json.load(config_file)
return self.normalize_configuration(conf=conf)

Expand Down
2 changes: 1 addition & 1 deletion src/powerapi/database/csvdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
# Open all files with csv and read first line
for filename in self.filenames:
try:
self.tmp_read[filename]['file'] = open(filename, 'r', encoding='utf-8')
self.tmp_read[filename]['file'] = open(filename, encoding='utf-8')

Check warning on line 93 in src/powerapi/database/csvdb.py

View check run for this annotation

Codecov / codecov/patch

src/powerapi/database/csvdb.py#L93

Added line #L93 was not covered by tests
self.tmp_read[filename]['reader'] = csv.DictReader(self.tmp_read[filename]['file'])
except FileNotFoundError as error:
raise CsvBadFilePathError(error) from error
Expand Down
2 changes: 1 addition & 1 deletion src/powerapi/database/file_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
:raise: StopIteration in stream mode when no report was found.
"""

with open(self.filename, 'r', encoding='utf-8') as file_object:
with open(self.filename, encoding='utf-8') as file_object:

Check warning on line 74 in src/powerapi/database/file_db.py

View check run for this annotation

Codecov / codecov/patch

src/powerapi/database/file_db.py#L74

Added line #L74 was not covered by tests
json_str = file_object.read()

if json_str is None:
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/cli/base_config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def load_configuration_from_json_file(file_name: str) -> dict:
"""
configuration = {}
path = parent_module.__path__[0]
with open(path + '/' + file_name, 'r', encoding='utf-8') as json_file:
with open(path + '/' + file_name, encoding='utf-8') as json_file:
configuration = json.load(json_file)
return configuration

Expand Down
6 changes: 3 additions & 3 deletions tests/utils/report/hwpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def extract_rapl_reports_with_2_sockets(number_of_reports: int) -> list[dict]:
:return: a list of reports. Each reports is a json dictionary
"""
path = parent_module.__path__[0]
with open(f'{path}/hwpc_rapl_2_socket.json', 'r', encoding='utf-8') as json_file:
with open(f'{path}/hwpc_rapl_2_socket.json', encoding='utf-8') as json_file:
reports = json.load(json_file)
return reports['reports'][:number_of_reports]

Expand All @@ -60,7 +60,7 @@ def extract_all_events_reports_with_2_sockets(number_of_reports: int) -> list[di
:return: a list of reports. Each reports is a json dictionary
"""
path = parent_module.__path__[0]
with open(f'{path}/hwpc_all_events_2_socket.json', 'r', encoding='utf-8') as json_file:
with open(f'{path}/hwpc_all_events_2_socket.json', encoding='utf-8') as json_file:
reports = json.load(json_file)
return reports['reports'][:number_of_reports]

Expand All @@ -71,6 +71,6 @@ def gen_HWPCReports(number_of_reports: int) -> list[HWPCReport]:
:return: a list of HWPCReport
"""
path = parent_module.__path__[0]
with open(f'{path}/hwpc.json', 'r', encoding='utf-8') as json_file:
with open(f'{path}/hwpc.json', encoding='utf-8') as json_file:
reports = list(map(HWPCReport.from_json, json.load(json_file)['reports']))
return reports[:number_of_reports]
Loading