Skip to content

Commit 8e88313

Browse files
committed
refactor: simplify pc_ properties using argument unpacking*
1 parent d5706fe commit 8e88313

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

coverage/results.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -342,20 +342,17 @@ def _percent(self, numerator: int, denominator: int) -> float:
342342
@property
343343
def pc_covered(self) -> float:
344344
"""Returns a single percentage value for coverage."""
345-
numerator, denominator = self.ratio_covered
346-
if self.n_statements == 0:
347-
return 100.0
348-
return self._percent(numerator, denominator)
345+
return self._percent(*self.ratio_covered)
349346

350347
@property
351348
def pc_statements(self) -> float:
352349
"""Returns the percentage covered for statements."""
353-
return self._percent(self.n_executed, self.n_statements)
350+
return self._percent(*self.ratio_statements)
354351

355352
@property
356353
def pc_branches(self) -> float:
357354
"""Returns the percentage covered for branches."""
358-
return self._percent(self.n_executed_branches, self.n_branches)
355+
return self._percent(*self.ratio_branches)
359356

360357
@property
361358
def pc_covered_str(self) -> str:

0 commit comments

Comments
 (0)