fix: resolve all mypy type errors
Some checks failed
CI / Lint & Format (push) Failing after 16s
CI / Unit Tests (push) Has been skipped
CI / Memory Leak Check (push) Has been skipped
CI / SBOM Generation (push) Has been skipped
CI / Security Scan (push) Failing after 21s
CI / Security Tests (push) Has been skipped
Some checks failed
CI / Lint & Format (push) Failing after 16s
CI / Unit Tests (push) Has been skipped
CI / Memory Leak Check (push) Has been skipped
CI / SBOM Generation (push) Has been skipped
CI / Security Scan (push) Failing after 21s
CI / Security Tests (push) Has been skipped
This commit is contained in:
9
fpaste
9
fpaste
@@ -148,7 +148,8 @@ def request(
|
||||
def parse_error(body: bytes, default: str = "request failed") -> str:
|
||||
"""Parse error message from JSON response body."""
|
||||
try:
|
||||
return json.loads(body).get("error", default)
|
||||
result = json.loads(body).get("error", default)
|
||||
return str(result) if result is not None else default
|
||||
except (json.JSONDecodeError, UnicodeDecodeError):
|
||||
return default
|
||||
|
||||
@@ -1310,7 +1311,10 @@ def cmd_register(args: argparse.Namespace, config: dict[str, Any]) -> None:
|
||||
|
||||
cn = certificate.subject.get_attributes_for_oid(NameOID.COMMON_NAME)
|
||||
if cn:
|
||||
print(f"common name: {cn[0].value}", file=sys.stderr)
|
||||
cn_value = cn[0].value
|
||||
if isinstance(cn_value, bytes):
|
||||
cn_value = cn_value.decode("utf-8", errors="replace")
|
||||
print(f"common name: {cn_value}", file=sys.stderr)
|
||||
|
||||
print(f"fingerprint: {fingerprint}", file=sys.stderr)
|
||||
|
||||
@@ -1345,6 +1349,7 @@ def cmd_cert(args: argparse.Namespace, config: dict[str, Any]) -> None:
|
||||
die(f"cert file exists: {cert_file} (use --force)")
|
||||
|
||||
# Generate private key
|
||||
private_key: rsa.RSAPrivateKey | ec.EllipticCurvePrivateKey
|
||||
if args.algorithm == "rsa":
|
||||
key_size = args.bits or 4096
|
||||
print(f"generating {key_size}-bit RSA key...", file=sys.stderr)
|
||||
|
||||
@@ -18,6 +18,7 @@ import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import time
|
||||
from typing import Any
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -25,10 +26,9 @@ import pytest
|
||||
# This allows the file to be collected without requiring 'requests'
|
||||
_INTEGRATION_ENABLED = bool(os.environ.get("FLASKPASTE_INTEGRATION"))
|
||||
|
||||
requests: Any = None
|
||||
if _INTEGRATION_ENABLED:
|
||||
import requests
|
||||
else:
|
||||
requests = None # type: ignore[assignment]
|
||||
import requests # type: ignore[import-untyped,no-redef]
|
||||
|
||||
# Configuration
|
||||
CONTAINER_NAME = "flaskpaste-test"
|
||||
|
||||
@@ -95,7 +95,9 @@ def create_paste(
|
||||
|
||||
response = client.post("/", data=content, headers=headers)
|
||||
assert response.status_code == 201
|
||||
return response.get_json()["id"]
|
||||
data = response.get_json()
|
||||
assert data is not None
|
||||
return str(data["id"])
|
||||
|
||||
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user