fix: remove padding from GLMOCREndToEndService and clean up ruff violations
- Drop image padding in GLMOCREndToEndService.recognize(); use raw image directly - Fix F821 undefined `padded` references replaced with `image` - Fix F601 duplicate dict key "≠" in converter - Fix F841 unused `image_cls_ids` variable in layout_postprocess - Fix E702 semicolon-separated statements in layout_postprocess - Fix UP031 percent-format replaced with f-string in logging_config - Auto-fix 44 additional ruff violations (import order, UP035/UP045/UP006, F401, F541) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
"""Application dependencies."""
|
||||
|
||||
from app.core.config import get_settings
|
||||
from app.services.converter import Converter
|
||||
from app.services.image_processor import ImageProcessor
|
||||
from app.services.layout_detector import LayoutDetector
|
||||
from app.services.ocr_service import GLMOCREndToEndService
|
||||
from app.services.converter import Converter
|
||||
from app.core.config import get_settings
|
||||
|
||||
# Global instances (initialized on startup)
|
||||
_layout_detector: LayoutDetector | None = None
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import logging
|
||||
import logging.handlers
|
||||
from pathlib import Path
|
||||
from typing import Any, Optional
|
||||
from typing import Any
|
||||
|
||||
from app.core.config import get_settings
|
||||
|
||||
@@ -18,10 +18,10 @@ class TimedRotatingAndSizeFileHandler(logging.handlers.TimedRotatingFileHandler)
|
||||
interval: int = 1,
|
||||
backupCount: int = 30,
|
||||
maxBytes: int = 100 * 1024 * 1024, # 100MB
|
||||
encoding: Optional[str] = None,
|
||||
encoding: str | None = None,
|
||||
delay: bool = False,
|
||||
utc: bool = False,
|
||||
atTime: Optional[Any] = None,
|
||||
atTime: Any | None = None,
|
||||
):
|
||||
"""Initialize handler with both time and size rotation.
|
||||
|
||||
@@ -58,14 +58,14 @@ class TimedRotatingAndSizeFileHandler(logging.handlers.TimedRotatingFileHandler)
|
||||
if self.stream is None:
|
||||
self.stream = self._open()
|
||||
if self.maxBytes > 0:
|
||||
msg = "%s\n" % self.format(record)
|
||||
msg = f"{self.format(record)}\n"
|
||||
self.stream.seek(0, 2) # Seek to end
|
||||
if self.stream.tell() + len(msg) >= self.maxBytes:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def setup_logging(log_dir: Optional[str] = None) -> logging.Logger:
|
||||
def setup_logging(log_dir: str | None = None) -> logging.Logger:
|
||||
"""Setup application logging with rotation by day and size.
|
||||
|
||||
Args:
|
||||
@@ -134,7 +134,7 @@ def setup_logging(log_dir: Optional[str] = None) -> logging.Logger:
|
||||
|
||||
|
||||
# Global logger instance
|
||||
_logger: Optional[logging.Logger] = None
|
||||
_logger: logging.Logger | None = None
|
||||
|
||||
|
||||
def get_logger() -> logging.Logger:
|
||||
|
||||
Reference in New Issue
Block a user