Change mypy config

This commit is contained in:
Alex Root Junior 2023-01-08 22:15:03 +02:00
parent bd59863c21
commit 46814b48e5
No known key found for this signature in database
GPG key ID: 074C1D455EBEA4AC
7 changed files with 49 additions and 27 deletions

View file

@ -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

View file

@ -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:

View file

@ -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(

View file

@ -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

View file

@ -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()

View file

@ -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")

View file

@ -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