Skip to content

Commit 0db380b

Browse files
authored
Merge pull request #581 from powerapi-ng/refactor/function-call-in-default-argument
refactor: Remove function call in default arguments
2 parents 050d78d + c549a82 commit 0db380b

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

.ruff.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ ignore = [
1717
"E501", # line too long
1818

1919
"B006", # mutable-argument-default
20-
"B008", # function-call-in-default-argument
20+
# "B008", # function-call-in-default-argument
2121
"F401", # unused-import
2222
"RUF013", # implicit-optional
2323

src/powerapi/report/procfs_report.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,9 @@ def _create_cgroup(_, cgroup_name, usage):
153153
usage[cgroup_name] = {}
154154

155155

156-
def create_report_root(cgroup_list, timestamp=datetime.fromtimestamp(0), sensor='toto', target='all'):
156+
def create_report_root(cgroup_list, timestamp=None, sensor='toto', target='all'):
157157
""" Create a default procfs report """
158-
sensor = ProcfsReport(timestamp=timestamp, sensor=sensor, target=target, usage={}, global_cpu_usage=0)
158+
sensor = ProcfsReport(timestamp=timestamp or datetime.now(), sensor=sensor, target=target, usage={}, global_cpu_usage=0)
159159
for (cgroup_id, cpu_usage) in cgroup_list:
160160
sensor.usage[cgroup_id] = cpu_usage
161161
return sensor

tests/unit/dispatch_rule/test_hwpc_dispatch_rule.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ def create_group_report(group_id, socket_list):
7373
return (group_id, group)
7474

7575

76-
def create_report_root(group_list, timestamp=datetime.fromtimestamp(0), sensor='toto', target='system'):
77-
sensor = HWPCReport(timestamp=timestamp, sensor=sensor, target=target, groups={})
76+
def create_report_root(group_list, timestamp=None, sensor='toto', target='system'):
77+
sensor = HWPCReport(timestamp=timestamp or datetime.now(), sensor=sensor, target=target, groups={})
7878
for (group_id, group) in group_list:
7979
sensor.groups[group_id] = group
8080
return sensor

tests/unit/dispatcher/test_dispatcher_actor.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ class Report1(Report):
8282
Fake report that can contain 2 or three values *a*, *b*, and *b2*
8383
"""
8484

85-
def __init__(self, a, b, b2=None, timestamp=datetime.now(), sensor='test_sensor', target='test_target'):
86-
Report.__init__(self, timestamp=timestamp, target=target, sensor=sensor)
85+
def __init__(self, a, b, b2=None, timestamp=None, sensor='test_sensor', target='test_target'):
86+
Report.__init__(self, timestamp=timestamp or datetime.now(), target=target, sensor=sensor)
8787
self.a = a
8888
self.b = b
8989
self.b2 = b2
@@ -141,8 +141,8 @@ class Report2(Report):
141141
Fake report that can contains two or three values : *a*, *c*, *c2*
142142
"""
143143

144-
def __init__(self, a, c, c2=None, timestamp=datetime.now(), sensor='test_sensor', target='test_target'):
145-
Report.__init__(self, timestamp=timestamp, target=target, sensor=sensor)
144+
def __init__(self, a, c, c2=None, timestamp=None, sensor='test_sensor', target='test_target'):
145+
Report.__init__(self, timestamp=timestamp or datetime.now(), target=target, sensor=sensor)
146146
self.a = a
147147
self.c = c
148148
self.c2 = c2
@@ -199,8 +199,8 @@ class Report3(Report):
199199
Fake report that contains same values as Report 1 and an other value
200200
"""
201201

202-
def __init__(self, a, b, d, timestamp=datetime.now(), sensor='test_sensor', target='test_target'):
203-
Report.__init__(self, timestamp=timestamp, target=target, sensor=sensor)
202+
def __init__(self, a, b, d, timestamp=None, sensor='test_sensor', target='test_target'):
203+
Report.__init__(self, timestamp=timestamp or datetime.now(), target=target, sensor=sensor)
204204
self.a = a
205205
self.b = b
206206
self.d = d

0 commit comments

Comments
 (0)