diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index e8c82566..d34a9940 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -28,4 +28,6 @@ jobs: - name: Test with pytest run: | pip install . - pytest tests/ -v + pytest tests/ -v --cov=rich --cov-report=xml + - name: Upload coverge to Codecov + uses: codecov/codecov-actions@1 diff --git a/rich/measure.py b/rich/measure.py index b5b56b54..35af5a0b 100644 --- a/rich/measure.py +++ b/rich/measure.py @@ -22,6 +22,11 @@ class Measurement(NamedTuple): return self.maximum - self.minimum def normalize(self) -> "Measurement": + """Get measurement that ensures that minimum <= maximum and minimum >= 0 + + Returns: + Measurement: A normalized measurement. + """ minimum, maximum = self minimum = min(max(0, minimum), maximum) return Measurement(max(0, minimum), max(0, max(minimum, maximum))) diff --git a/rich/palette.py b/rich/palette.py index fa145606..5fb7ff96 100644 --- a/rich/palette.py +++ b/rich/palette.py @@ -17,7 +17,14 @@ class Palette: # This is somewhat inefficient and needs caching @lru_cache(maxsize=1024) def match(self, color: Tuple[int, int, int]) -> int: - """Find a color from a palette that most closely matches a given color""" + """Find a color from a palette that most closely matches a given color. + + Args: + color (Tuple[int, int, int]): RGB components in range 0 > 255. + + Returns: + int: Index of closes matching color. + """ red1, green1, blue1 = color _sqrt = sqrt