Skip to content

Commit 2838409

Browse files
authored
Merge pull request #539 from powerapi-ng/refactor/printf-string-formatting
refactor: Remove usage of printf string formatting
2 parents 6cc7b67 + 8c6a5c2 commit 2838409

File tree

6 files changed

+6
-9
lines changed

6 files changed

+6
-9
lines changed

.ruff.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ select = [
1616
ignore = [
1717
"E501", # line too long
1818

19-
"UP031", # printf-string-formatting
2019
"UP035", # deprecated-import
2120
"B006", # mutable-argument-default
2221
"B008", # function-call-in-default-argument

src/powerapi/report/control_report.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def __init__(self, timestamp: datetime, sensor: str, target: str, action: str, p
5555
self.parameters = parameters
5656

5757
def __repr__(self) -> str:
58-
return 'ControlReport(%s, %s, %s, %s, %s, %s)' % (self.timestamp, self.sensor, self.target, self.action, self.parameters, str(self.metadata))
58+
return f'ControlReport({self.timestamp}, {self.sensor}, {self.target}, {self.action}, {self.parameters}, {self.metadata})'
5959

6060
def __eq__(self, other: Any) -> bool:
6161
if not isinstance(other, ControlReport):

src/powerapi/report/hwpc_report.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@ def __init__(self, timestamp: datetime, sensor: str, target: str, groups: dict[s
8484
self.groups = groups
8585

8686
def __repr__(self) -> str:
87-
return 'HWCPReport(%s, %s, %s, %s)' % (
88-
self.timestamp, self.sensor, self.target, sorted(self.groups.keys()))
87+
return f'HWPCReport({self.timestamp}, {self.sensor}, {self.target}, {sorted(self.groups.keys())}, {self.metadata})'
8988

9089
def __eq__(self, other) -> bool:
9190
if not isinstance(other, HWPCReport):

src/powerapi/report/power_report.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ def __init__(self, timestamp: datetime, sensor: str, target: str, power: float,
5656
self.power = power
5757

5858
def __repr__(self) -> str:
59-
return 'PowerReport(%s, %s, %s, %f, %s)' % (
60-
self.timestamp, self.sensor, self.target, self.power, str(self.metadata))
59+
return f'PowerReport({self.timestamp}, {self.sensor}, {self.target}, {self.power}, {self.metadata})'
6160

6261
def __eq__(self, other) -> bool:
6362
if not isinstance(other, PowerReport):

src/powerapi/report/procfs_report.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def __init__(self, timestamp: datetime, sensor: str, target: str, usage: dict, g
6969
self.global_cpu_usage = global_cpu_usage
7070

7171
def __repr__(self) -> str:
72-
return 'ProcfsReport(%s, %s, %s, %s, %s)' % (self.timestamp, self.sensor, self.target, sorted(self.usage.keys()), str(self.metadata))
72+
return f'ProcfsReport({self.timestamp}, {self.sensor}, {self.target}, {sorted(self.usage.keys())}, {self.metadata})'
7373

7474
def __eq__(self, other) -> bool:
7575
if not isinstance(other, ProcfsReport):

src/powerapi/report/report.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ def __init__(self, timestamp: datetime, sensor: str, target: str, metadata: dict
8888
self.dispatcher_report_id = None
8989

9090
def __str__(self):
91-
return '%s(%s, %s, %s)' % (self.__class__.__name__, self.timestamp, self.sensor, self.target)
91+
return f'{self.__class__.__name__}({self.timestamp}, {self.sensor}, {self.target}, {self.metadata})'
9292

9393
def __repr__(self):
94-
return '%s(%s, %s, %s)' % (self.__class__.__name__, self.timestamp, self.sensor, self.target)
94+
return f'{self.__class__.__name__}({self.timestamp}, {self.sensor}, {self.target}, {self.metadata})'
9595

9696
def __eq__(self, other):
9797
return (isinstance(other, type(self)) and

0 commit comments

Comments
 (0)