diff --git a/Makefile b/Makefile index 7d664107..dfdca2f1 100644 --- a/Makefile +++ b/Makefile @@ -70,7 +70,7 @@ clean: lint: isort --check-only $(code_dir) black --check --diff $(code_dir) - ruff $(code_dir) + ruff $(package_dir) mypy $(package_dir) .PHONY: reformat diff --git a/aiogram/dispatcher/dispatcher.py b/aiogram/dispatcher/dispatcher.py index 7a83199f..2c1a8cf5 100644 --- a/aiogram/dispatcher/dispatcher.py +++ b/aiogram/dispatcher/dispatcher.py @@ -107,13 +107,13 @@ class Dispatcher(Router): return self.fsm.storage @property - def parent_router(self) -> None: + def parent_router(self) -> Optional[Router]: """ Dispatcher has no parent router and can't be included to any other routers or dispatchers :return: """ - pass + return None # noqa: RET501 @parent_router.setter def parent_router(self, value: Router) -> None: diff --git a/aiogram/dispatcher/flags.py b/aiogram/dispatcher/flags.py index d7d82874..82cdbc04 100644 --- a/aiogram/dispatcher/flags.py +++ b/aiogram/dispatcher/flags.py @@ -94,7 +94,7 @@ def extract_flags(handler: Union["HandlerObject", Dict[str, Any]]) -> Dict[str, handler = handler["handler"] if not hasattr(handler, "flags"): return {} - return handler.flags # type: ignore + return handler.flags def get_flag( diff --git a/aiogram/methods/base.py b/aiogram/methods/base.py index 72c68ebb..066fd434 100644 --- a/aiogram/methods/base.py +++ b/aiogram/methods/base.py @@ -2,7 +2,16 @@ from __future__ import annotations import abc import secrets -from typing import TYPE_CHECKING, Any, Dict, Generator, Generic, Optional, TypeVar +from typing import ( + TYPE_CHECKING, + Any, + Dict, + Generator, + Generic, + Optional, + TypeVar, + Union, +) from pydantic import BaseConfig, BaseModel, Extra, root_validator from pydantic.generics import GenericModel diff --git a/examples/multibot.py b/examples/multibot.py index 8f086469..b6a324cd 100644 --- a/examples/multibot.py +++ b/examples/multibot.py @@ -2,6 +2,7 @@ from os import getenv from typing import Any, Dict, Union from aiohttp import web +from finite_state_machine import form_router from aiogram import Bot, Dispatcher, F, Router from aiogram.client.session.aiohttp import AiohttpSession @@ -15,7 +16,6 @@ from aiogram.webhook.aiohttp_server import ( TokenBasedRequestHandler, setup_application, ) -from finite_state_machine import form_router main_router = Router() diff --git a/examples/web_app/main.py b/examples/web_app/main.py index abbd8e6d..0d58042c 100644 --- a/examples/web_app/main.py +++ b/examples/web_app/main.py @@ -3,12 +3,12 @@ from os import getenv from aiohttp.web import run_app from aiohttp.web_app import Application +from handlers import my_router +from routes import check_data_handler, demo_handler, send_message_handler from aiogram import Bot, Dispatcher from aiogram.types import MenuButtonWebApp, WebAppInfo from aiogram.webhook.aiohttp_server import SimpleRequestHandler, setup_application -from handlers import my_router -from routes import check_data_handler, demo_handler, send_message_handler TELEGRAM_TOKEN = getenv("TELEGRAM_TOKEN") APP_BASE_URL = getenv("APP_BASE_URL") diff --git a/pyproject.toml b/pyproject.toml index 48acb1f7..68fe8530 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -185,7 +185,9 @@ select = [ "T20", "Q", "RET", - "I" +] +ignore = [ + "F401" ] src = ["aiogram", "tests"] exclude = [ @@ -240,27 +242,38 @@ exclude_lines = [ ] [tool.mypy] -strict = true +plugins = "pydantic.mypy" +python_version = "3.8" +show_error_codes = true +show_error_context = true +pretty = true +ignore_missing_imports = false +warn_unused_configs = true +disallow_subclassing_any = true +disallow_any_generics = true +disallow_untyped_calls = true +disallow_untyped_defs = true +disallow_incomplete_defs = true +check_untyped_defs = true +disallow_untyped_decorators = true +no_implicit_optional = true +warn_redundant_casts = true +warn_unused_ignores = true +warn_return_any = true +follow_imports_for_stubs = true +namespace_packages = true +show_absolute_path = true [[tool.mypy.overrides]] -module = "mypy-aiofiles" -ignore_missing_imports = true - -[[tool.mypy.overrides]] -module = "mypy-async_lru" -ignore_missing_imports = true - -[[tool.mypy.overrides]] -module = "mypy-uvloop" -ignore_missing_imports = true - -[[tool.mypy.overrides]] -module = "mypy-redis.*" -ignore_missing_imports = true - -[[tool.mypy.overrides]] -module = "mypy-babel.*" +module = [ + "aiofiles", + "async_lru", + "uvloop", + "redis.*", + "babel.*", +] ignore_missing_imports = true +disallow_untyped_defs = true [tool.black] line-length = 99