mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-07-27 16:29:52 +03:00
Fix multiple annotation of abstract class
This commit is contained in:
parent
d9ef60782a
commit
52a9e70354
|
@ -1,14 +1,14 @@
|
||||||
from typing import Optional, TypeAlias
|
from typing import Optional, TypeAlias, TypeVar
|
||||||
|
|
||||||
from ...tl import abcs, types
|
from ...tl import abcs, types
|
||||||
from .buttons import Button, InlineButton
|
from .buttons import Button, InlineButton
|
||||||
|
|
||||||
|
AnyButton = TypeVar("AnyButton", bound=Button)
|
||||||
|
AnyInlineButton = TypeVar("AnyInlineButton", bound=InlineButton)
|
||||||
|
|
||||||
|
|
||||||
def _build_keyboard_rows(
|
def _build_keyboard_rows(
|
||||||
btns: list[Button]
|
btns: list[AnyButton] | list[list[AnyButton]],
|
||||||
| list[list[Button]]
|
|
||||||
| list[InlineButton]
|
|
||||||
| list[list[InlineButton]],
|
|
||||||
) -> list[abcs.KeyboardButtonRow]:
|
) -> list[abcs.KeyboardButtonRow]:
|
||||||
# list[button] -> list[list[button]]
|
# list[button] -> list[list[button]]
|
||||||
# This does allow for "invalid" inputs (mixing lists and non-lists), but that's acceptable.
|
# This does allow for "invalid" inputs (mixing lists and non-lists), but that's acceptable.
|
||||||
|
@ -29,7 +29,7 @@ class Keyboard:
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
buttons: list[Button] | list[list[Button]],
|
buttons: list[AnyButton] | list[list[AnyButton]],
|
||||||
resize: bool,
|
resize: bool,
|
||||||
single_use: bool,
|
single_use: bool,
|
||||||
selective: bool,
|
selective: bool,
|
||||||
|
@ -49,7 +49,9 @@ class Keyboard:
|
||||||
class InlineKeyboard:
|
class InlineKeyboard:
|
||||||
__slots__ = ("_raw",)
|
__slots__ = ("_raw",)
|
||||||
|
|
||||||
def __init__(self, buttons: list[InlineButton] | list[list[InlineButton]]) -> None:
|
def __init__(
|
||||||
|
self, buttons: list[AnyInlineButton] | list[list[AnyInlineButton]]
|
||||||
|
) -> None:
|
||||||
self._raw = types.ReplyInlineMarkup(rows=_build_keyboard_rows(buttons))
|
self._raw = types.ReplyInlineMarkup(rows=_build_keyboard_rows(buttons))
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user