From 81957ca188731cabf8e1746fbb9cbfa95d562554 Mon Sep 17 00:00:00 2001 From: tech Date: Thu, 28 May 2026 17:50:32 +0800 Subject: [PATCH] fix: clean up type annotations and unused imports Co-Authored-By: Claude Opus 4.7 --- src/jianda_proxy/proxy.py | 14 +++++++------- tests/test_daemon.py | 4 +--- tests/test_proxy.py | 4 ---- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/jianda_proxy/proxy.py b/src/jianda_proxy/proxy.py index 19ea40a..3711fab 100644 --- a/src/jianda_proxy/proxy.py +++ b/src/jianda_proxy/proxy.py @@ -9,9 +9,9 @@ logger = logging.getLogger("jianda_proxy") class ProxyHandler(http.server.BaseHTTPRequestHandler): protocol_version = "HTTP/1.1" - REMOTE_DOMAIN = "" - UPSTREAM_IP = "" - UPSTREAM_PORT = 0 + REMOTE_DOMAIN: str = "" + UPSTREAM_IP: str = "" + UPSTREAM_PORT: int = 0 def _proxy_request(self, target_host, target_port, target_path, body=None): body_len = int(self.headers.get("Content-Length", 0)) @@ -39,12 +39,12 @@ class ProxyHandler(http.server.BaseHTTPRequestHandler): if kl in ("transfer-encoding", "connection"): continue if kl == "content-length": - self.send_header(k, len(resp_body)) + self.send_header(k, str(len(resp_body))) sent_cl = True continue self.send_header(k, v) if not sent_cl: - self.send_header("Content-Length", len(resp_body)) + self.send_header("Content-Length", str(len(resp_body))) self.end_headers() self.wfile.write(resp_body) finally: @@ -73,8 +73,8 @@ class ProxyHandler(http.server.BaseHTTPRequestHandler): do_GET = do_POST = do_PUT = do_DELETE = do_HEAD = do_PATCH = _do - def log_message(self, fmt, *args): - logger.info("%s - %s", self.address_string(), fmt % args) + def log_message(self, format, *args): + logger.info("%s - %s", self.address_string(), format % args) def create_server(config): diff --git a/tests/test_daemon.py b/tests/test_daemon.py index eaf492c..60ec502 100644 --- a/tests/test_daemon.py +++ b/tests/test_daemon.py @@ -1,7 +1,5 @@ -import os -import tempfile import pytest -from unittest.mock import patch, MagicMock +from unittest.mock import patch from jianda_proxy.daemon import ( read_pid, write_pid, diff --git a/tests/test_proxy.py b/tests/test_proxy.py index 83b734c..9b455d6 100644 --- a/tests/test_proxy.py +++ b/tests/test_proxy.py @@ -1,8 +1,4 @@ -import threading -import http.client -import time import pytest -from unittest.mock import MagicMock, patch from jianda_proxy.proxy import create_server