From dd67a9a0b1e39ae97b44d6266f7f4782191f688a Mon Sep 17 00:00:00 2001 From: mshqq Date: Sat, 15 Aug 2026 00:17:06 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D1=82=D1=8C=20=D0=BD=D0=B5=D0=B4=D0=BE=D1=81=D1=82=D0=B0=D1=8E?= =?UTF-8?q?=D1=89=D0=B8=D0=B5=20=D1=82=D0=B8=D0=BF=D1=8B=20=D0=B2=D0=BE?= =?UTF-8?q?=D0=B7=D0=B2=D1=80=D0=B0=D1=89=D0=B0=D0=B5=D0=BC=D1=8B=D1=85=20?= =?UTF-8?q?=D0=B7=D0=BD=D0=B0=D1=87=D0=B5=D0=BD=D0=B8=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Аннотации для методов моделей и utils, фикс SAFE_ENV_FILES (tuple[str] -> tuple[str, str, str] для 3-элементного кортежа), убраны избыточные повторные аннотации и list -> list[dict] в EnvFileRule. --- app/models/__init__.py | 2 +- app/models/project.py | 2 +- app/models/user.py | 6 +++--- app/scanner/rules/env_file.py | 8 ++++---- app/utils.py | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/models/__init__.py b/app/models/__init__.py index 61f4b5d..0370a8d 100644 --- a/app/models/__init__.py +++ b/app/models/__init__.py @@ -3,4 +3,4 @@ from app.models.scan import Scan from app.models.user import User -__all__ = ["Finding", "Project", "Scan", "User"] +__all__: list[str] = ["Finding", "Project", "Scan", "User"] diff --git a/app/models/project.py b/app/models/project.py index d944cd4..c069e5d 100644 --- a/app/models/project.py +++ b/app/models/project.py @@ -25,5 +25,5 @@ class Project(db.Model): __table_args__ = (db.UniqueConstraint("owner_id", "repo_url"),) - def create_ownership_token(self): + def create_ownership_token(self) -> None: self.ownership_token = secrets.token_urlsafe(16) diff --git a/app/models/user.py b/app/models/user.py index 6ef0c8c..be3d7ad 100644 --- a/app/models/user.py +++ b/app/models/user.py @@ -19,11 +19,11 @@ class User(UserMixin, db.Model): "Project", back_populates="owner", cascade="all, delete-orphan" ) - def __repr__(self): + def __repr__(self) -> str: return f"" - def set_password(self, password): + def set_password(self, password) -> None: self.password_hash = generate_password_hash(password) - def check_password(self, password): + def check_password(self, password) -> bool: return check_password_hash(self.password_hash, password) diff --git a/app/scanner/rules/env_file.py b/app/scanner/rules/env_file.py index 232b221..55a12b8 100644 --- a/app/scanner/rules/env_file.py +++ b/app/scanner/rules/env_file.py @@ -2,7 +2,7 @@ from app.scanner.base import Rule, ScanContext -SAFE_ENV_FILES: tuple[str] = (".env.example", ".env.sample", ".env.template") +SAFE_ENV_FILES: tuple[str, str, str] = (".env.example", ".env.sample", ".env.template") MAX_ENV_FILE_SIZE: int = 200 * 1024 @@ -32,7 +32,7 @@ class EnvFileRule(Rule): source = "regex" def scan(self, ctx: ScanContext) -> list[dict]: - findings: list = [] + findings: list[dict] = [] for rel_path in ctx.files: file_name = _basename(rel_path) @@ -67,8 +67,8 @@ def _scan_lines(self, file_path: str, text: str, commit_sha: str) -> list[dict]: except ValueError: continue - key: str = key.strip() - value: str = _strip_quotes(value.strip()) + key = key.strip() + value = _strip_quotes(value.strip()) if not value: continue diff --git a/app/utils.py b/app/utils.py index bb88ffb..2313d48 100644 --- a/app/utils.py +++ b/app/utils.py @@ -1,5 +1,5 @@ from datetime import datetime, timezone -def utcnow(): +def utcnow() -> datetime: return datetime.now(timezone.utc)