Skip to content

Conversation

@kb-nik
Copy link

@kb-nik kb-nik commented Oct 16, 2025

No description provided.



def highlight(text, style=None):
def highlight(text: str, style: Optional[List[Style]] = None) -> str:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лучше сделать Optional[List[Style]] -> list[Style] | None, мы используем новый стандарт питона, поэтому так будет красивее, правильно и меньше импортов

from math import ceil
from urllib.parse import urljoin
from urllib.request import Request, urlopen
from typing import List, Optional, Any, Tuple, Dict, Iterator, Set, IO, Mapping
Copy link
Collaborator

@navichok26 navichok26 Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Из импортов нужно 100% убрать List(list), Optional(| None), Tuple(tuple), Dict(dict). Возможно убрать Set(можно заменить на set наверно)

import subprocess
import time
import threading
from re import Pattern
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лучше убрать, до этого импортировали уже re, снизу лучше писать re.Pattern тогда



def check_script_source(source, interpreter):
def check_script_source(source: str, interpreter: Optional[str]) -> List[str]:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional и List

raise APIException(conn.read())

return json.loads(conn.read().decode())
return json.loads(conn.read().decode()) # type: ignore[no-any-return]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лучше через isinstance проверить что мы получили dict и дальше с ним работать, если не dict то кидать ошибку, а type: ignore убрать



def post_flags(args, flags):
def post_flags(args: argparse.Namespace, flags: List[Dict[str, str]]) -> None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

List и Dict

self._lock = threading.RLock()
def __init__(self) -> None:
self._flags_seen: Set[str] = set()
self._queue: List[Dict[str, str]] = []
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

List, Dict и Set

self._lock: threading.RLock = threading.RLock()

def add(self, flags, team_name):
def add(self, flags: Set[str], team_name: str) -> None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set

self._queue.append({"flag": item, "team": team_name})

def pick_flags(self):
def pick_flags(self) -> List[Dict[str, str]]:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

List и Dict



def display_sploit_output(team_name, output_lines):
def display_sploit_output(team_name: str, output_lines: List[str]) -> None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

List

stream: IO[bytes],
args: argparse.Namespace,
team_name: str,
flag_format: Pattern[str],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re.Pattern

self.instances = {}
def __init__(self) -> None:
self._counter: int = 0
self.instances: Dict[int, subprocess.Popen[bytes]] = {}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dict

team_name: str,
team_addr: Optional[str],
attack_no: int,
flag_format: Pattern[str],
Copy link
Collaborator

@navichok26 navichok26 Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional, Pattern и Tuple

Comment on lines +677 to +678
config: Optional[Dict[str, Any]] = None
flag_format: Optional[re.Pattern[str]] = None
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional и Dict


def show_time_limit_info(args, config, max_runtime, attack_no):
def show_time_limit_info(
args: argparse.Namespace, config: Dict[str, Any], max_runtime: float, attack_no: int
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dict

Comment on lines +541 to +544
team_addr: Optional[str],
attack_no: int,
max_runtime: float,
flag_format: Pattern[str],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional и Pattern

Comment on lines +633 to +634
args: argparse.Namespace, teams: Dict[str, str], attack_no: int
) -> Mapping[str, Optional[str]]:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dict, Optional

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants