Skip to content

Commit

Permalink
Sort praw.models.reddit.widgets.SubredditWidgetsModeration.add_button…
Browse files Browse the repository at this point in the history
…_widget arguments
  • Loading branch information
LilSpazJoekp committed Jan 14, 2022
1 parent 188229f commit 8df424d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 26 deletions.
50 changes: 28 additions & 22 deletions praw/models/reddit/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from typing import TYPE_CHECKING, Any, Dict, List, Union

from ...const import API_PATH
from ...util import _deprecate_args
from ...util.cache import cachedproperty
from ..base import PRAWBase
from ..list.base import BaseList
Expand Down Expand Up @@ -60,16 +61,16 @@ class CalendarConfiguration(PRAWBase):
.. include:: ../../typical_attributes.rst
=================== ==================================================
=================== ================================================
Attribute Description
=================== ==================================================
=================== ================================================
``numEvents`` The number of events to display on the calendar.
``showDate`` Whether or not to show the dates of events.
``showDescription`` Whether or not to show the descriptions of events.
``showLocation`` Whether or not to show the locations of events.
``showTime`` Whether or not to show the times of events.
``showTitle`` Whether or not to show the titles of events.
=================== ==================================================
``showDate`` Whether to show the dates of events.
``showDescription`` Whether to show the descriptions of events.
``showLocation`` Whether to show the locations of events.
``showTime`` Whether to show the times of events.
``showTitle`` Whether to show the titles of events.
=================== ================================================
"""

Expand Down Expand Up @@ -409,21 +410,21 @@ def _create_widget(self, payload: Dict[str, Any]) -> WidgetType:
widget.subreddit = self._subreddit
return widget

@_deprecate_args("short_name", "description", "buttons", "styles")
def add_button_widget(
self,
short_name: str,
description: str,
*,
buttons: List[
Dict[str, Union[Dict[str, str], str, int, Dict[str, Union[str, int]]]]
],
description: str,
short_name: str,
styles: Dict[str, str],
**other_settings,
) -> "praw.models.ButtonWidget":
r"""Add and return a :class:`.ButtonWidget`.
"""Add and return a :class:`.ButtonWidget`.
:param short_name: A name for the widget, no longer than 30 characters.
:param description: Markdown text to describe the widget.
:param buttons: A list of ``dict``\ s describing buttons, as specified in
:param buttons: A list of dictionaries describing buttons, as specified in
`Reddit docs`_. As of this writing, the format is:
Each button is either a text button or an image button. A text button looks
Expand Down Expand Up @@ -490,9 +491,11 @@ def add_button_widget(
An image ``hoverState`` may be paired with a text widget, and a text
``hoverState`` may be paired with an image widget.
:param styles: A ``dict`` with keys ``backgroundColor`` and ``headerColor``, and
values of hex colors. For example, ``{"backgroundColor": "#FFFF66",
"headerColor": "#3333EE"}``.
:param description: Markdown text to describe the widget.
:param short_name: A name for the widget, no longer than 30 characters.
:param styles: A dictionary with keys ``"backgroundColor"`` and
``"headerColor"``, and values of hex colors. For example,
``{"backgroundColor": "#FFFF66", "headerColor": "#3333EE"}``.
:returns: The created :class:`.ButtonWidget`.
Expand Down Expand Up @@ -532,7 +535,10 @@ def add_button_widget(
]
styles = {"backgroundColor": "#FFFF66", "headerColor": "#3333EE"}
new_widget = widget_moderation.add_button_widget(
"Things to click", "Click some of these *cool* links!", buttons, styles
short_name="Things to click",
description="Click some of these *cool* links!",
buttons=buttons,
styles=styles,
)
"""
Expand Down Expand Up @@ -1193,20 +1199,20 @@ class Calendar(Widget):
.. include:: ../../typical_attributes.rst
================= ============================================================
================= =====================================================
Attribute Description
================= ============================================================
================= =====================================================
``configuration`` A ``dict`` describing the calendar configuration.
``data`` A list of ``dict``\ s that represent events.
``id`` The widget ID.
``kind`` The widget kind (always ``"calendar"``).
``requiresSync`` A ``bool`` representing whether or not the calendar requires
``requiresSync`` A ``bool`` representing whether the calendar requires
synchronization.
``shortName`` The short name of the widget.
``styles`` A ``dict`` with the keys ``"backgroundColor"`` and
``"headerColor"``.
``subreddit`` The :class:`.Subreddit` the button widget belongs to.
================= ============================================================
================= =====================================================
"""

Expand Down
8 changes: 4 additions & 4 deletions tests/integration/models/reddit/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ def test_create_and_update_and_delete(self, _):
},
]
widget = widgets.mod.add_button_widget(
"Things to click",
"Click some of these *cool* links!",
buttons,
styles,
short_name="Things to click",
description="Click some of these *cool* links!",
buttons=buttons,
styles=styles,
)

assert isinstance(widget, ButtonWidget)
Expand Down

0 comments on commit 8df424d

Please sign in to comment.