Method: pylint.utils.linterstats.merge_stats
Calls: 38, Exceptions: 17, Paths: 2Back
Path 1: 21 calls (0.55)
list (21)
LinterStats (21)
1def merge_stats(stats: list[LinterStats]) -> LinterStats:
2 """Used to merge multiple stats objects into a new one when pylint is run in
3 parallel mode.
4 """
5 merged = LinterStats()
6 for stat in stats:
7 merged.bad_names["argument"] += stat.bad_names["argument"]
8 merged.bad_names["attr"] += stat.bad_names["attr"]
9 merged.bad_names["klass"] += stat.bad_names["klass"]
10 merged.bad_names["class_attribute"] += stat.bad_names["class_attribute"]
11 merged.bad_names["class_const"] += stat.bad_names["class_const"]
12 merged.bad_names["const"] += stat.bad_names["const"]
13 merged.bad_names["inlinevar"] += stat.bad_names["inlinevar"]
14 merged.bad_names["function"] += stat.bad_names["function"]
15 merged.bad_names["method"] += stat.bad_names["method"]
16 merged.bad_names["module"] += stat.bad_names["module"]
17 merged.bad_names["variable"] += stat.bad_names["variable"]
18 merged.bad_names["typevar"] += stat.bad_names["typevar"]
19
20 for mod_key, mod_value in stat.by_module.items():
21 merged.by_module[mod_key] = mod_value
22
23 for msg_key, msg_value in stat.by_msg.items():
24 try:
25 merged.by_msg[msg_key] += msg_value
26 except KeyError:
27 merged.by_msg[msg_key] = msg_value
28
29 merged.code_type_count["code"] += stat.code_type_count["code"]
30 merged.code_type_count["comment"] += stat.code_type_count["comment"]
31 merged.code_type_count["docstring"] += stat.code_type_count["docstring"]
32 merged.code_type_count["empty"] += stat.code_type_count["empty"]
33 merged.code_type_count["total"] += stat.code_type_count["total"]
34
35 for dep_key, dep_value in stat.dependencies.items():
36 try:
37 merged.dependencies[dep_key].update(dep_value)
38 except KeyError:
39 merged.dependencies[dep_key] = dep_value
40
41 merged.duplicated_lines["nb_duplicated_lines"] += stat.duplicated_lines[
42 "nb_duplicated_lines"
43 ]
44 merged.duplicated_lines["percent_duplicated_lines"] += stat.duplicated_lines[
45 "percent_duplicated_lines"
46 ]
47
48 merged.node_count["function"] += stat.node_count["function"]
49 merged.node_count["klass"] += stat.node_count["klass"]
50 merged.node_count["method"] += stat.node_count["method"]
51 merged.node_count["module"] += stat.node_count["module"]
52
53 merged.undocumented["function"] += stat.undocumented["function"]
54 merged.undocumented["klass"] += stat.undocumented["klass"]
55 merged.undocumented["method"] += stat.undocumented["method"]
56 merged.undocumented["module"] += stat.undocumented["module"]
57
58 merged.convention += stat.convention
59 merged.error += stat.error
60 merged.fatal += stat.fatal
61 merged.info += stat.info
62 merged.refactor += stat.refactor
63 merged.statement += stat.statement
64 merged.warning += stat.warning
65
66 merged.global_note += stat.global_note
67 return merged
Path 2: 17 calls (0.45)
list (17)
LinterStats (17)
KeyError (17)
1def merge_stats(stats: list[LinterStats]) -> LinterStats:
2 """Used to merge multiple stats objects into a new one when pylint is run in
3 parallel mode.
4 """
5 merged = LinterStats()
6 for stat in stats:
7 merged.bad_names["argument"] += stat.bad_names["argument"]
8 merged.bad_names["attr"] += stat.bad_names["attr"]
9 merged.bad_names["klass"] += stat.bad_names["klass"]
10 merged.bad_names["class_attribute"] += stat.bad_names["class_attribute"]
11 merged.bad_names["class_const"] += stat.bad_names["class_const"]
12 merged.bad_names["const"] += stat.bad_names["const"]
13 merged.bad_names["inlinevar"] += stat.bad_names["inlinevar"]
14 merged.bad_names["function"] += stat.bad_names["function"]
15 merged.bad_names["method"] += stat.bad_names["method"]
16 merged.bad_names["module"] += stat.bad_names["module"]
17 merged.bad_names["variable"] += stat.bad_names["variable"]
18 merged.bad_names["typevar"] += stat.bad_names["typevar"]
19
20 for mod_key, mod_value in stat.by_module.items():
21 merged.by_module[mod_key] = mod_value
22
23 for msg_key, msg_value in stat.by_msg.items():
24 try:
25 merged.by_msg[msg_key] += msg_value
26 except KeyError:
27 merged.by_msg[msg_key] = msg_value
28
29 merged.code_type_count["code"] += stat.code_type_count["code"]
30 merged.code_type_count["comment"] += stat.code_type_count["comment"]
31 merged.code_type_count["docstring"] += stat.code_type_count["docstring"]
32 merged.code_type_count["empty"] += stat.code_type_count["empty"]
33 merged.code_type_count["total"] += stat.code_type_count["total"]
34
35 for dep_key, dep_value in stat.dependencies.items():
36 try:
37 merged.dependencies[dep_key].update(dep_value)
38 except KeyError:
39 merged.dependencies[dep_key] = dep_value
40
41 merged.duplicated_lines["nb_duplicated_lines"] += stat.duplicated_lines[
42 "nb_duplicated_lines"
43 ]
44 merged.duplicated_lines["percent_duplicated_lines"] += stat.duplicated_lines[
45 "percent_duplicated_lines"
46 ]
47
48 merged.node_count["function"] += stat.node_count["function"]
49 merged.node_count["klass"] += stat.node_count["klass"]
50 merged.node_count["method"] += stat.node_count["method"]
51 merged.node_count["module"] += stat.node_count["module"]
52
53 merged.undocumented["function"] += stat.undocumented["function"]
54 merged.undocumented["klass"] += stat.undocumented["klass"]
55 merged.undocumented["method"] += stat.undocumented["method"]
56 merged.undocumented["module"] += stat.undocumented["module"]
57
58 merged.convention += stat.convention
59 merged.error += stat.error
60 merged.fatal += stat.fatal
61 merged.info += stat.info
62 merged.refactor += stat.refactor
63 merged.statement += stat.statement
64 merged.warning += stat.warning
65
66 merged.global_note += stat.global_note
67 return merged