добавляет правило TC200

This commit is contained in:
Maxim Slipenko 2024-08-22 12:17:54 +03:00
parent 9ca5264c6d
commit 29be6782d6
No known key found for this signature in database
GPG Key ID: 6DEA9FA7DE98C7D6
13 changed files with 26 additions and 26 deletions

View File

@ -5,4 +5,4 @@ max-line-length = 88
count = true
extend-ignore = E203,E701
extend-select = TC010
extend-select = TC010,TC200

View File

@ -18,7 +18,7 @@ if TYPE_CHECKING:
from .config_manager import ConfigManager
def create_control(key: str, config: ConfigManager):
def create_control(key: str, config: "ConfigManager"):
value = config.get(key)
meta = config.get_meta(key)
@ -85,7 +85,7 @@ def create_control(key: str, config: ConfigManager):
return dbc.Row(row, className="mb-3 mx-1")
def build_settings_tree(config: ConfigManager):
def build_settings_tree(config: "ConfigManager"):
tree = {}
for key, value in config._metadata.items():
@ -134,7 +134,7 @@ def create_settings_components(tree, level=0):
return components
def get_miniapp_blueprint(config: ConfigManager, prefix: str):
def get_miniapp_blueprint(config: "ConfigManager", prefix: str):
Roles: "type[IRoles]" = get_module("standard.roles", "Roles")
roles = Roles()

View File

@ -35,7 +35,7 @@ def get_approved_chat_id() -> list:
@deprecated("Use ChatIDFilter or own implementation")
def chat_not_in_approve(message: Message) -> bool:
def chat_not_in_approve(message: "Message") -> bool:
chat_id = message.chat.id
if chat_id in get_approved_chat_id():
# log(f"Chat in approve list: {chat_id}")
@ -51,7 +51,7 @@ class ChatIDFilter(BaseFilter):
self.approved_chats = approved_chats
super().__init__()
async def __call__(self, message: Message, bot: Bot) -> bool:
async def __call__(self, message: "Message", bot: "Bot") -> bool:
chat_id = message.chat.id
approved_chats = self.approved_chats or get_approved_chat_id()
@ -71,7 +71,7 @@ class ChatNotInApproveFilter(ChatIDFilter):
class ChatModerOrAdminFilter(BaseFilter):
async def __call__(self, message: Message, bot: Bot) -> bool:
async def __call__(self, message: "Message", bot: "Bot") -> bool:
if not ROLES_MODULE_LOADED:
raise Exception("Roles module not loaded")

View File

@ -47,7 +47,7 @@ def format_commands(commands_dict):
return "\n".join(formatted_commands)
async def help(message: Message):
async def help(message: "Message"):
commands = ""
version = ""

View File

@ -79,7 +79,7 @@ verification_tasks = MultiKeyDict()
last_success = {}
async def new_member_handler(event: ChatMemberUpdated, bot: Bot):
async def new_member_handler(event: "ChatMemberUpdated", bot: Bot):
# НЕ СРАБОТАЕТ, ЕСЛИ ЧЕЛОВЕК УЖЕ ОГРАНИЧЕН В ПРАВАХ (RESTRICTED)
if event.new_chat_member.status == ChatMemberStatus.MEMBER:
task = task_manager.build_random_task(event, bot)
@ -88,7 +88,7 @@ async def new_member_handler(event: ChatMemberUpdated, bot: Bot):
verification_tasks.add(task, keys)
async def left_member_handler(event: ChatMemberUpdated, bot: Bot):
async def left_member_handler(event: "ChatMemberUpdated", bot: Bot):
user_id = event.from_user.id
chat_id = event.chat.id
@ -145,7 +145,7 @@ async def success_end(task: BaseTask):
last_success[task.from_chat_id] = message.message_id
async def handle_poll_verification(answer: PollAnswer, bot: Bot):
async def handle_poll_verification(answer: "PollAnswer", bot: Bot):
key = key_from_poll(answer.poll_id)
if not verification_tasks.exists(key):
return

View File

@ -17,8 +17,8 @@ if TYPE_CHECKING:
class BaseTask:
def __init__(
self,
event: ChatMemberUpdated,
bot: Bot,
event: "ChatMemberUpdated",
bot: "Bot",
timeout_func=None,
attempt_number=1,
max_attempts=1,

View File

@ -123,8 +123,8 @@ class SimpleInlineButtonsTask(SimpleVariantsBaseTask):
class SimplePollTask(SimpleVariantsBaseTask):
def __init__(
self,
event: ChatMemberUpdated,
bot: Bot,
event: "ChatMemberUpdated",
bot: "Bot",
timeout_func=None,
attempt_number=1,
max_attempts=1,

View File

@ -17,7 +17,7 @@ def user_mention(user: User, mode=ParseMode.HTML):
raise ValueError(f"Unknown parse mode {mode}")
async def mute_user(chat_id, user_id, until, bot: Bot):
async def mute_user(chat_id, user_id, until, bot: "Bot"):
end_time = until + int(time.time())
await bot.restrict_chat_member(
chat_id,
@ -43,7 +43,7 @@ async def mute_user(chat_id, user_id, until, bot: Bot):
)
async def unmute_user(chat_id, user_id, bot: Bot):
async def unmute_user(chat_id, user_id, bot: "Bot"):
await bot.restrict_chat_member(
chat_id,
user_id,

View File

@ -20,8 +20,8 @@ def get_module_directory(module_name):
return os.path.dirname(module_path)
async def register_bot_webhook(app: FastAPI, bot: Bot, dp: Dispatcher):
async def handle_webhook(request: Request):
async def register_bot_webhook(app: "FastAPI", bot: "Bot", dp: "Dispatcher"):
async def handle_webhook(request: "Request"):
try:
update = Update.model_validate(await request.json(), context={"bot": bot})
await dp.feed_update(bot, update)

View File

@ -41,5 +41,5 @@ class AbstractLoader:
def info(self) -> ModuleInfo:
raise NotImplementedError
def load(self) -> types.ModuleType:
def load(self) -> "types.ModuleType":
raise NotImplementedError

View File

@ -18,12 +18,12 @@ async def set_chat_menu_button(menu_button):
await app.bot.set_chat_menu_button(menu_button=menu_button)
def register_router(router: Router):
def register_router(router: "Router"):
app = Singleton()
app.storage["_routers"].append(router)
def register_outer_message_middleware(middleware: BaseMiddleware):
def register_outer_message_middleware(middleware: "BaseMiddleware"):
app = Singleton()
app.storage["_outer_message_middlewares"].append(middleware)

View File

@ -52,7 +52,7 @@ class RestrictedPythonPolicy(RestrictingNodeTransformer):
return self.node_contents_visit(node)
"""
def visit_AnnAssign(self, node: AnnAssign) -> Any:
def visit_AnnAssign(self, node: "AnnAssign") -> Any:
# missing in RestrictingNodeTransformer
# this doesn't need the logic that is in visit_Assign
# because it doesn't have a "targets" attribute,

View File

@ -19,9 +19,9 @@ class SingletonMeta(type):
class Singleton(metaclass=SingletonMeta):
bot: Bot
dp: Dispatcher = None
modules_manager: ModulesManager = None
bot: "Bot"
dp: "Dispatcher" = None
modules_manager: "ModulesManager" = None
storage = {
"_fsm_storage": MemoryStorage(),
"_routers": [],