Skip to content

Commit

Permalink
[handlers] fix typing when registering on class level
Browse files Browse the repository at this point in the history
  • Loading branch information
david-lev committed Oct 25, 2024
1 parent eace973 commit 405192a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 115 deletions.
16 changes: 8 additions & 8 deletions pywa/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ def __init__(self: WhatsApp):
raise TypeError("This class cannot be instantiated.")

def on_raw_update(
self: WhatsApp = None,
self: WhatsApp | Filter = None,
filters: Filter = None,
priority: int = 0,
) -> Callable[[_RawUpdateCallback], _RawUpdateCallback] | _RawUpdateCallback:
Expand Down Expand Up @@ -628,7 +628,7 @@ def deco(callback: _RawUpdateCallback) -> _RawUpdateCallback:
return deco

def on_message(
self: WhatsApp = None,
self: WhatsApp | Filter = None,
filters: Filter = None,
priority: int = 0,
) -> Callable[[_MessageCallback], _MessageCallback] | _MessageCallback:
Expand Down Expand Up @@ -671,7 +671,7 @@ def deco(callback: _MessageCallback) -> _MessageCallback:
return deco

def on_callback_button(
self: WhatsApp = None,
self: WhatsApp | Filter = None,
filters: Filter = None,
factory: type[CallbackData] | None = None,
priority: int = 0,
Expand Down Expand Up @@ -724,7 +724,7 @@ def deco(callback: _CallbackButtonCallback) -> _CallbackButtonCallback:
return deco

def on_callback_selection(
self: WhatsApp = None,
self: WhatsApp | Filter = None,
filters: Filter = None,
factory: type[CallbackData] | None = None,
priority: int = 0,
Expand Down Expand Up @@ -777,7 +777,7 @@ def deco(callback: _CallbackSelectionCallback) -> _CallbackSelectionCallback:
return deco

def on_message_status(
self: WhatsApp = None,
self: WhatsApp | Filter = None,
filters: Filter = None,
factory: type[CallbackData] | None = None,
priority: int = 0,
Expand Down Expand Up @@ -834,7 +834,7 @@ def deco(callback: _MessageStatusCallback) -> _MessageStatusCallback:
return deco

def on_chat_opened(
self: WhatsApp = None,
self: WhatsApp | Filter = None,
filters: Filter = None,
priority: int = 0,
) -> Callable[[_ChatOpenedCallback], _ChatOpenedCallback] | _ChatOpenedCallback:
Expand Down Expand Up @@ -876,7 +876,7 @@ def deco(callback: _ChatOpenedCallback) -> _ChatOpenedCallback:
return deco

def on_template_status(
self: WhatsApp = None,
self: WhatsApp | Filter = None,
filters: Filter = None,
priority: int = 0,
) -> (
Expand Down Expand Up @@ -925,7 +925,7 @@ def deco(callback: _TemplateStatusCallback) -> _TemplateStatusCallback:
return deco

def on_flow_completion(
self: WhatsApp = None,
self: WhatsApp | Filter = None,
filters: Filter = None,
priority: int = 0,
) -> (
Expand Down
54 changes: 0 additions & 54 deletions pywa/types/base_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,60 +203,6 @@ def reply_text(
... quote=True,
... )
Example with keyboard buttons:
>>> from pywa.types import Button
>>> msg.reply_text(
... header="Hello from PyWa!",
... text="What can I help you with?",
... footer="Powered by PyWa",
... buttons=[
... Button("Help", data="help"),
... Button("About", data="about"),
... ],
... quote=True
... )
Example with a section list:
>>> from pywa.types import SectionList, Section, SectionRow
>>> msg.reply_text(
... header="Hello from PyWa!",
... text="What can I help you with?",
... footer="Powered by PyWa",
... buttons=SectionList(
... button_title="Choose an option",
... sections=[
... Section(
... title="Help",
... rows=[
... SectionRow(
... title="Help",
... callback_data="help",
... description="Get help with PyWa",
... ),
... SectionRow(
... title="About",
... callback_data="about",
... description="Learn more about PyWa",
... ),
... ],
... ),
... Section(
... title="Other",
... rows=[
... SectionRow(
... title="GitHub",
... callback_data="github",
... description="View the PyWa GitHub repository",
... ),
... ],
... ),
... ],
... ),
... quote=True
... )
Args:
text: The text to reply with (markdown allowed, max 4096 characters).
header: The header of the reply (if buttons are provided, optional, up to 60 characters,
Expand Down
53 changes: 0 additions & 53 deletions pywa_async/types/base_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,59 +58,6 @@ async def reply_text(
... quote=True,
... )
Example with keyboard buttons:
>>> from pywa.types import Button
>>> msg.reply_text(
... header="Hello from PyWa!",
... text="What can I help you with?",
... footer="Powered by PyWa",
... buttons=[
... Button("Help", data="help"),
... Button("About", data="about"),
... ],
... quote=True
... )
Example with a section list:
>>> from pywa.types import SectionList, Section, SectionRow
>>> msg.reply_text(
... header="Hello from PyWa!",
... text="What can I help you with?",
... footer="Powered by PyWa",
... buttons=SectionList(
... button_title="Choose an option",
... sections=[
... Section(
... title="Help",
... rows=[
... SectionRow(
... title="Help",
... callback_data="help",
... description="Get help with PyWa",
... ),
... SectionRow(
... title="About",
... callback_data="about",
... description="Learn more about PyWa",
... ),
... ],
... ),
... Section(
... title="Other",
... rows=[
... SectionRow(
... title="GitHub",
... callback_data="github",
... description="View the PyWa GitHub repository",
... ),
... ],
... ),
... ],
... ),
... quote=True
... )
Args:
text: The text to reply with (markdown allowed, max 4096 characters).
Expand Down

0 comments on commit 405192a

Please sign in to comment.