[go: up one dir, main page]

Skip to content

Commit

Permalink
Fix mypy issues
Browse files Browse the repository at this point in the history
  • Loading branch information
FeeeeK committed Mar 21, 2023
1 parent 31dd1e7 commit 71b4da3
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 145 deletions.
93 changes: 37 additions & 56 deletions vkbottle/framework/bot/bot.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import TYPE_CHECKING, NoReturn, Optional, Tuple, overload

from typing_extensions import deprecated
from typing_extensions import deprecated # type: ignore

from vkbottle.api import API
from vkbottle.callback import BotCallback
Expand All @@ -21,7 +21,42 @@
from vkbottle.polling import ABCPolling


class Bot(ABCFramework): # type: ignore
class Bot(ABCFramework):
@deprecated(
"task_each_event is deprecated and will be removed in future versions",
)
@overload
def __init__(
self,
token: Optional["Token"] = None,
api: Optional["ABCAPI"] = None,
polling: Optional["ABCPolling"] = None,
callback: Optional["ABCCallback"] = None,
loop_wrapper: Optional[LoopWrapper] = None,
router: Optional["ABCRouter"] = None,
labeler: Optional["ABCLabeler"] = None,
state_dispenser: Optional["ABCStateDispenser"] = None,
error_handler: Optional["ABCErrorHandler"] = None,
task_each_event: bool = ...,
):
...

@overload
def __init__(
self,
token: Optional["Token"] = None,
api: Optional["ABCAPI"] = None,
polling: Optional["ABCPolling"] = None,
callback: Optional["ABCCallback"] = None,
loop_wrapper: Optional[LoopWrapper] = None,
router: Optional["ABCRouter"] = None,
labeler: Optional["ABCLabeler"] = None,
state_dispenser: Optional["ABCStateDispenser"] = None,
error_handler: Optional["ABCErrorHandler"] = None,
task_each_event: Optional[bool] = None,
):
...

def __init__(
self,
token: Optional["Token"] = None,
Expand Down Expand Up @@ -114,57 +149,3 @@ async def setup_webhook(self) -> Tuple[str, str]:

async def process_event(self, event: dict):
await self.router.route(event, self.api)


if TYPE_CHECKING:

class Bot(Bot):
@deprecated(
"task_each_event is deprecated and will be removed in future versions",
)
@overload
def __init__(
self,
token: Optional["Token"] = None,
api: Optional["ABCAPI"] = None,
polling: Optional["ABCPolling"] = None,
callback: Optional["ABCCallback"] = None,
loop_wrapper: Optional[LoopWrapper] = None,
router: Optional["ABCRouter"] = None,
labeler: Optional["ABCLabeler"] = None,
state_dispenser: Optional["ABCStateDispenser"] = None,
error_handler: Optional["ABCErrorHandler"] = None,
task_each_event=...,
):
...

@overload
def __init__(
self,
token: Optional["Token"] = None,
api: Optional["ABCAPI"] = None,
polling: Optional["ABCPolling"] = None,
callback: Optional["ABCCallback"] = None,
loop_wrapper: Optional[LoopWrapper] = None,
router: Optional["ABCRouter"] = None,
labeler: Optional["ABCLabeler"] = None,
state_dispenser: Optional["ABCStateDispenser"] = None,
error_handler: Optional["ABCErrorHandler"] = None,
task_each_event=None,
):
...

def __init__(
self,
token: Optional["Token"] = None,
api: Optional["ABCAPI"] = None,
polling: Optional["ABCPolling"] = None,
callback: Optional["ABCCallback"] = None,
loop_wrapper: Optional[LoopWrapper] = None,
router: Optional["ABCRouter"] = None,
labeler: Optional["ABCLabeler"] = None,
state_dispenser: Optional["ABCStateDispenser"] = None,
error_handler: Optional["ABCErrorHandler"] = None,
task_each_event=None,
):
...
88 changes: 35 additions & 53 deletions vkbottle/framework/user/user.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import asyncio
from typing import TYPE_CHECKING, NoReturn, Optional, Type, overload

from typing_extensions import deprecated
from typing_extensions import deprecated # type: ignore

from vkbottle.api import API
from vkbottle.dispatch import BuiltinStateDispenser, Router
Expand All @@ -20,8 +20,41 @@
from vkbottle.polling import ABCPolling


class User(ABCFramework): # type: ignore
class User(ABCFramework):
@deprecated(
"task_each_event is deprecated and will be removed in future versions",
)
@overload
def __init__(
self,
token: Optional["Token"] = None,
api: Optional["ABCAPI"] = None,
polling: Optional["ABCPolling"] = None,
loop_wrapper: Optional[LoopWrapper] = None,
router: Optional["ABCRouter"] = None,
labeler: Optional["ABCLabeler"] = None,
state_dispenser: Optional["ABCStateDispenser"] = None,
error_handler: Optional["ABCErrorHandler"] = None,
task_each_event: bool = ...,
):
...

@overload
def __init__(
self,
token: Optional["Token"] = None,
api: Optional["ABCAPI"] = None,
polling: Optional["ABCPolling"] = None,
loop_wrapper: Optional[LoopWrapper] = None,
router: Optional["ABCRouter"] = None,
labeler: Optional["ABCLabeler"] = None,
state_dispenser: Optional["ABCStateDispenser"] = None,
error_handler: Optional["ABCErrorHandler"] = None,
task_each_event: Optional[bool] = None,
):
...

def __init__( # type: ignore
self,
token: Optional["Token"] = None,
api: Optional["ABCAPI"] = None,
Expand Down Expand Up @@ -116,54 +149,3 @@ def run_forever(self) -> NoReturn: # type: ignore
logger.info("Loop will be run forever")
self.loop_wrapper.add_task(self.run_polling())
self.loop_wrapper.run()


if TYPE_CHECKING:

class User(User):
@deprecated(
"task_each_event is deprecated and will be removed in future versions",
)
@overload
def __init__(
self,
token: Optional["Token"] = None,
api: Optional["ABCAPI"] = None,
polling: Optional["ABCPolling"] = None,
loop_wrapper: Optional[LoopWrapper] = None,
router: Optional["ABCRouter"] = None,
labeler: Optional["ABCLabeler"] = None,
state_dispenser: Optional["ABCStateDispenser"] = None,
error_handler: Optional["ABCErrorHandler"] = None,
task_each_event=None,
):
...

@overload
def __init__(
self,
token: Optional["Token"] = None,
api: Optional["ABCAPI"] = None,
polling: Optional["ABCPolling"] = None,
loop_wrapper: Optional[LoopWrapper] = None,
router: Optional["ABCRouter"] = None,
labeler: Optional["ABCLabeler"] = None,
state_dispenser: Optional["ABCStateDispenser"] = None,
error_handler: Optional["ABCErrorHandler"] = None,
task_each_event=None,
):
...

def __init__(
self,
token: Optional["Token"] = None,
api: Optional["ABCAPI"] = None,
polling: Optional["ABCPolling"] = None,
loop_wrapper: Optional[LoopWrapper] = None,
router: Optional["ABCRouter"] = None,
labeler: Optional["ABCLabeler"] = None,
state_dispenser: Optional["ABCStateDispenser"] = None,
error_handler: Optional["ABCErrorHandler"] = None,
task_each_event=None,
):
...
60 changes: 24 additions & 36 deletions vkbottle/tools/uploader/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,31 @@
Bytes = Union[bytes, BytesIO]


class BaseUploader(ABC): # type: ignore
class BaseUploader(ABC): # type: ignore
@overload
@deprecated(
"generate_attachment_strings in uploaders is deprecated"
" use .raw_upload() to get raw response or .upload() to get attachment string"
)
def __init__(
self,
api: "ABCAPI",
attachment_name: Optional[str] = None,
generate_attachment_strings: bool = ...,
**kwargs,
):
...

@overload
def __init__(
self,
api: "ABCAPI",
attachment_name: Optional[str] = None,
**kwargs,
):
...

def __init__( # type: ignore
self,
api: "ABCAPI",
attachment_name: Optional[str] = None,
Expand Down Expand Up @@ -83,38 +106,3 @@ async def read(file_source: Union[str, "Bytes"]) -> "Bytes":

def __repr__(self) -> str:
return f"<Uploader {self.__class__.__name__} with api {self.api!r}"


if TYPE_CHECKING:

class BaseUploader(BaseUploader):
@overload
@deprecated(
"generate_attachment_strings in uploaders is deprecated"
" use .raw_upload() to get raw response or .upload() to get attachment string"
)
def __init__(
self,
api: "ABCAPI",
attachment_name: Optional[str] = None,
generate_attachment_strings: bool = ...,
**kwargs,
):
...

@overload
def __init__(
self,
api: "ABCAPI",
attachment_name: Optional[str] = None,
**kwargs,
):
...

def __init__( # type: ignore
self,
api: "ABCAPI",
attachment_name: Optional[str] = None,
**kwargs,
):
...

0 comments on commit 71b4da3

Please sign in to comment.