From ccf69f5e0ed9dc3a0b03cfc8a71cfcd33c34b3c7 Mon Sep 17 00:00:00 2001 From: Isaac Benitez Date: Mon, 3 Oct 2022 16:47:21 -0700 Subject: [PATCH 1/2] Added type annotations to docstrings --- adafruit_display_shapes/circle.py | 12 ++++++------ adafruit_display_shapes/line.py | 10 +++++----- adafruit_display_shapes/polygon.py | 4 ++-- adafruit_display_shapes/rect.py | 18 +++++++++--------- adafruit_display_shapes/roundrect.py | 22 +++++++++++----------- adafruit_display_shapes/sparkline.py | 22 +++++++++++----------- adafruit_display_shapes/triangle.py | 18 +++++++++--------- 7 files changed, 53 insertions(+), 53 deletions(-) diff --git a/adafruit_display_shapes/circle.py b/adafruit_display_shapes/circle.py index e7295d1..cbcd917 100644 --- a/adafruit_display_shapes/circle.py +++ b/adafruit_display_shapes/circle.py @@ -36,14 +36,14 @@ class Circle(RoundRect): # pylint: disable=too-few-public-methods, invalid-name """A circle. - :param x0: The x-position of the center. - :param y0: The y-position of the center. - :param r: The radius of the circle. - :param fill: The color to fill the circle. Can be a hex value for a color or + :param int x0: The x-position of the center. + :param int y0: The y-position of the center. + :param int r: The radius of the circle. + :param int fill: (Optional) The color to fill the circle. Can be a hex value for a color or ``None`` for transparent. - :param outline: The outline of the circle. Can be a hex value for a color or + :param int outline: (Optional) The outline of the circle. Can be a hex value for a color or ``None`` for no outline. - :param stroke: Used for the outline. Will not change the radius. + :param int stroke: Used for the outline. Will not change the radius. """ diff --git a/adafruit_display_shapes/line.py b/adafruit_display_shapes/line.py index 30af37c..2d5c40d 100644 --- a/adafruit_display_shapes/line.py +++ b/adafruit_display_shapes/line.py @@ -36,11 +36,11 @@ class Line(Polygon): # pylint: disable=too-many-arguments,invalid-name, too-few-public-methods """A line. - :param x0: The x-position of the first vertex. - :param y0: The y-position of the first vertex. - :param x1: The x-position of the second vertex. - :param y1: The y-position of the second vertex. - :param color: The color of the line. + :param int x0: The x-position of the first vertex. + :param int y0: The y-position of the first vertex. + :param int x1: The x-position of the second vertex. + :param int y1: The y-position of the second vertex. + :param int color: The color of the line. """ def __init__( diff --git a/adafruit_display_shapes/polygon.py b/adafruit_display_shapes/polygon.py index a7c1040..46d2c6a 100644 --- a/adafruit_display_shapes/polygon.py +++ b/adafruit_display_shapes/polygon.py @@ -36,8 +36,8 @@ class Polygon(displayio.TileGrid): # pylint: disable=too-many-arguments,invalid-name """A polygon. - :param points: A list of (x, y) tuples of the points - :param outline: The outline of the polygon. Can be a hex value for a color or + :param list points: A list of (x, y) tuples of the points + :param int outline: (Optional) The outline of the polygon. Can be a hex value for a color or ``None`` for no outline. """ diff --git a/adafruit_display_shapes/rect.py b/adafruit_display_shapes/rect.py index 7655955..74b1238 100644 --- a/adafruit_display_shapes/rect.py +++ b/adafruit_display_shapes/rect.py @@ -35,16 +35,16 @@ class Rect(displayio.TileGrid): """A rectangle. - :param x: The x-position of the top left corner. - :param y: The y-position of the top left corner. - :param width: The width of the rectangle. - :param height: The height of the rectangle. - :param fill: The color to fill the rectangle. Can be a hex value for a color or - ``None`` for transparent. - :param outline: The outline of the rectangle. Can be a hex value for a color or + :param int x: The x-position of the top left corner. + :param int y: The y-position of the top left corner. + :param int width: The width of the rectangle. + :param int height: The height of the rectangle. + :param int fill: (Optional) The color to fill the rectangle. Can be a hex value for a color or + ``None`` for transparent. + :param int outline: (Optional) The outline of the rectangle. Can be a hex value for a color or ``None`` for no outline. - :param stroke: Used for the outline. Will not change the outer bound size set by ``width`` and - ``height``. + :param int stroke: Used for the outline. Will not change the outer bound size set by ``width`` + and ``height``. """ diff --git a/adafruit_display_shapes/roundrect.py b/adafruit_display_shapes/roundrect.py index 9b7e97f..2393801 100644 --- a/adafruit_display_shapes/roundrect.py +++ b/adafruit_display_shapes/roundrect.py @@ -26,17 +26,17 @@ class RoundRect(displayio.TileGrid): # pylint: disable=too-many-arguments """A round-corner rectangle. - :param x: The x-position of the top left corner. - :param y: The y-position of the top left corner. - :param width: The width of the rounded-corner rectangle. - :param height: The height of the rounded-corner rectangle. - :param r: The radius of the rounded corner. - :param fill: The color to fill the rounded-corner rectangle. Can be a hex value for a color or - ``None`` for transparent. - :param outline: The outline of the rounded-corner rectangle. Can be a hex value for a color or - ``None`` for no outline. - :param stroke: Used for the outline. Will not change the outer bound size set by ``width`` and - ``height``. + :param int x: The x-position of the top left corner. + :param int y: The y-position of the top left corner. + :param int width: The width of the rounded-corner rectangle. + :param int height: The height of the rounded-corner rectangle. + :param int r: The radius of the rounded corner. + :param int fill: (Optional) The color to fill the rounded-corner rectangle. Can be a hex value + for a color or ``None`` for transparent. + :param int outline: (Optional) The outline of the rounded-corner rectangle. Can be a hex value + for a color or ``None`` for no outline. + :param int stroke: Used for the outline. Will not change the outer bound size set by ``width`` + and ``height``. """ diff --git a/adafruit_display_shapes/sparkline.py b/adafruit_display_shapes/sparkline.py index ccb9241..f554376 100644 --- a/adafruit_display_shapes/sparkline.py +++ b/adafruit_display_shapes/sparkline.py @@ -51,15 +51,15 @@ class Sparkline(displayio.Group): # pylint: disable=too-many-arguments """A sparkline graph. - :param width: Width of the sparkline graph in pixels - :param height: Height of the sparkline graph in pixels - :param max_items: Maximum number of values housed in the sparkline - :param dyn_xpitch: dynamically change xpitch (True) - :param y_min: Lower range for the y-axis. Set to None for autorange. - :param y_max: Upper range for the y-axis. Set to None for autorange. - :param x: X-position on the screen, in pixels - :param y: Y-position on the screen, in pixels - :param color: Line color, the default value is 0xFFFFFF (WHITE) + :param int width: Width of the sparkline graph in pixels + :param int height: Height of the sparkline graph in pixels + :param int max_items: Maximum number of values housed in the sparkline + :param bool dyn_xpitch: (Optional) Dynamically change xpitch (True) + :param int y_min: (Optional) Lower range for the y-axis. Set to None for autorange. + :param int y_max: (Optional) Upper range for the y-axis. Set to None for autorange. + :param int x: X-position on the screen, in pixels + :param int y: Y-position on the screen, in pixels + :param int color: Line color, the default value is 0xFFFFFF (WHITE) Note: If dyn_xpitch is True (default), the sparkline will allways span the complete width. Otherwise, the sparkline will grow when you @@ -113,8 +113,8 @@ def clear_values(self) -> None: def add_value(self, value: float, update: bool = True) -> None: """Add a value to the sparkline. - :param value: The value to be added to the sparkline - :param update: trigger recreation of primitives + :param float value: The value to be added to the sparkline + :param bool update: trigger recreation of primitives Note: when adding multiple values it is more efficient to call this method with parameter 'update=False' and then to manually diff --git a/adafruit_display_shapes/triangle.py b/adafruit_display_shapes/triangle.py index 6f49913..5cb8ef9 100644 --- a/adafruit_display_shapes/triangle.py +++ b/adafruit_display_shapes/triangle.py @@ -36,15 +36,15 @@ class Triangle(Polygon): # pylint: disable=too-many-arguments,invalid-name """A triangle. - :param x0: The x-position of the first vertex. - :param y0: The y-position of the first vertex. - :param x1: The x-position of the second vertex. - :param y1: The y-position of the second vertex. - :param x2: The x-position of the third vertex. - :param y2: The y-position of the third vertex. - :param fill: The color to fill the triangle. Can be a hex value for a color or - ``None`` for transparent. - :param outline: The outline of the triangle. Can be a hex value for a color or + :param int x0: The x-position of the first vertex. + :param int y0: The y-position of the first vertex. + :param int x1: The x-position of the second vertex. + :param int y1: The y-position of the second vertex. + :param int x2: The x-position of the third vertex. + :param int y2: The y-position of the third vertex. + :param int fill: (Optional) The color to fill the triangle. Can be a hex value for a color or + ``None`` for transparent. + :param int outline: (Optional) The outline of the triangle. Can be a hex value for a color or ``None`` for no outline. """ # pylint: disable=too-many-locals From 8bfe627161b71d9138f544bec4a2eb607cfee990 Mon Sep 17 00:00:00 2001 From: Isaac Benitez Date: Tue, 4 Oct 2022 13:17:13 -0700 Subject: [PATCH 2/2] Fix parameters that can take None --- adafruit_display_shapes/circle.py | 4 ++-- adafruit_display_shapes/polygon.py | 2 +- adafruit_display_shapes/rect.py | 4 ++-- adafruit_display_shapes/roundrect.py | 4 ++-- adafruit_display_shapes/sparkline.py | 4 ++-- adafruit_display_shapes/triangle.py | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/adafruit_display_shapes/circle.py b/adafruit_display_shapes/circle.py index cbcd917..1b774a5 100644 --- a/adafruit_display_shapes/circle.py +++ b/adafruit_display_shapes/circle.py @@ -39,9 +39,9 @@ class Circle(RoundRect): :param int x0: The x-position of the center. :param int y0: The y-position of the center. :param int r: The radius of the circle. - :param int fill: (Optional) The color to fill the circle. Can be a hex value for a color or + :param int|None fill: The color to fill the circle. Can be a hex value for a color or ``None`` for transparent. - :param int outline: (Optional) The outline of the circle. Can be a hex value for a color or + :param int|None outline: The outline of the circle. Can be a hex value for a color or ``None`` for no outline. :param int stroke: Used for the outline. Will not change the radius. diff --git a/adafruit_display_shapes/polygon.py b/adafruit_display_shapes/polygon.py index 46d2c6a..757ec6e 100644 --- a/adafruit_display_shapes/polygon.py +++ b/adafruit_display_shapes/polygon.py @@ -37,7 +37,7 @@ class Polygon(displayio.TileGrid): """A polygon. :param list points: A list of (x, y) tuples of the points - :param int outline: (Optional) The outline of the polygon. Can be a hex value for a color or + :param int|None outline: The outline of the polygon. Can be a hex value for a color or ``None`` for no outline. """ diff --git a/adafruit_display_shapes/rect.py b/adafruit_display_shapes/rect.py index 74b1238..f8e6876 100644 --- a/adafruit_display_shapes/rect.py +++ b/adafruit_display_shapes/rect.py @@ -39,9 +39,9 @@ class Rect(displayio.TileGrid): :param int y: The y-position of the top left corner. :param int width: The width of the rectangle. :param int height: The height of the rectangle. - :param int fill: (Optional) The color to fill the rectangle. Can be a hex value for a color or + :param int|None fill: The color to fill the rectangle. Can be a hex value for a color or ``None`` for transparent. - :param int outline: (Optional) The outline of the rectangle. Can be a hex value for a color or + :param int|None outline: The outline of the rectangle. Can be a hex value for a color or ``None`` for no outline. :param int stroke: Used for the outline. Will not change the outer bound size set by ``width`` and ``height``. diff --git a/adafruit_display_shapes/roundrect.py b/adafruit_display_shapes/roundrect.py index 2393801..c48ee50 100644 --- a/adafruit_display_shapes/roundrect.py +++ b/adafruit_display_shapes/roundrect.py @@ -31,9 +31,9 @@ class RoundRect(displayio.TileGrid): :param int width: The width of the rounded-corner rectangle. :param int height: The height of the rounded-corner rectangle. :param int r: The radius of the rounded corner. - :param int fill: (Optional) The color to fill the rounded-corner rectangle. Can be a hex value + :param int|None fill: The color to fill the rounded-corner rectangle. Can be a hex value for a color or ``None`` for transparent. - :param int outline: (Optional) The outline of the rounded-corner rectangle. Can be a hex value + :param int|None outline: The outline of the rounded-corner rectangle. Can be a hex value for a color or ``None`` for no outline. :param int stroke: Used for the outline. Will not change the outer bound size set by ``width`` and ``height``. diff --git a/adafruit_display_shapes/sparkline.py b/adafruit_display_shapes/sparkline.py index f554376..0ca9661 100644 --- a/adafruit_display_shapes/sparkline.py +++ b/adafruit_display_shapes/sparkline.py @@ -55,8 +55,8 @@ class Sparkline(displayio.Group): :param int height: Height of the sparkline graph in pixels :param int max_items: Maximum number of values housed in the sparkline :param bool dyn_xpitch: (Optional) Dynamically change xpitch (True) - :param int y_min: (Optional) Lower range for the y-axis. Set to None for autorange. - :param int y_max: (Optional) Upper range for the y-axis. Set to None for autorange. + :param int|None y_min: Lower range for the y-axis. Set to None for autorange. + :param int|None y_max: Upper range for the y-axis. Set to None for autorange. :param int x: X-position on the screen, in pixels :param int y: Y-position on the screen, in pixels :param int color: Line color, the default value is 0xFFFFFF (WHITE) diff --git a/adafruit_display_shapes/triangle.py b/adafruit_display_shapes/triangle.py index 5cb8ef9..6d88464 100644 --- a/adafruit_display_shapes/triangle.py +++ b/adafruit_display_shapes/triangle.py @@ -42,9 +42,9 @@ class Triangle(Polygon): :param int y1: The y-position of the second vertex. :param int x2: The x-position of the third vertex. :param int y2: The y-position of the third vertex. - :param int fill: (Optional) The color to fill the triangle. Can be a hex value for a color or + :param int|None fill: The color to fill the triangle. Can be a hex value for a color or ``None`` for transparent. - :param int outline: (Optional) The outline of the triangle. Can be a hex value for a color or + :param int|None outline: The outline of the triangle. Can be a hex value for a color or ``None`` for no outline. """ # pylint: disable=too-many-locals