style: format all Python files with Black

Apply Black formatter to the entire codebase for consistent code style.

Co-Authored-By: Claude (glm-5) <noreply@anthropic.com>
This commit is contained in:
Misaka
2026-02-26 22:44:03 +08:00
parent 1b16842a2c
commit 3b7c00377f
46 changed files with 1488 additions and 974 deletions

View File

@@ -5,6 +5,7 @@
使用 dataclass 定义所有配置项的结构和类型。
"""
from dataclasses import dataclass, field
from typing import Optional
from pathlib import Path
@@ -13,6 +14,7 @@ from enum import Enum
class DatabaseType(str, Enum):
"""数据库类型枚举"""
SQLSERVER = "sqlserver"
MYSQL = "mysql"
@@ -57,6 +59,7 @@ class ERPConfig:
@dataclass
class SQLServerConfig:
"""SQL Server 特定配置"""
driver: str = "ODBC Driver 18 for SQL Server"
trust_server_certificate: str = "yes"
@@ -74,6 +77,7 @@ class SQLServerConfig:
@dataclass
class MySQLConfig:
"""MySQL 特定配置"""
host: str = ""
port: int = 3306
charset: str = "utf8mb4"
@@ -167,7 +171,9 @@ class PathConfig:
data_dir=get_env("PATH_DATA_DIR", "D:/python/playwrite/data/"),
production_id_file=get_env("PATH_PRODUCTION_ID_FILE", "ProductionID.txt"),
default_output=get_env("PATH_DEFAULT_OUTPUT", "离散备料计划维护_合并.xlsx"),
validation_output=get_env("PATH_VALIDATION_OUTPUT", "物料状态校验结果.xlsx"),
validation_output=get_env(
"PATH_VALIDATION_OUTPUT", "物料状态校验结果.xlsx"
),
)
def validate(self) -> list[str]:
@@ -200,7 +206,9 @@ class ExtractionConfig:
verbose=get_env_bool("EXTRACTION_VERBOSE", True),
auto_convert=get_env_bool("EXTRACTION_AUTO_CONVERT", True),
merge_batches=get_env_bool("EXTRACTION_MERGE_BATCHES", True),
enable_db_persistence=get_env_bool("EXTRACTION_ENABLE_DB_PERSISTENCE", False),
enable_db_persistence=get_env_bool(
"EXTRACTION_ENABLE_DB_PERSISTENCE", False
),
)
def validate(self) -> list[str]:
@@ -246,7 +254,7 @@ class ValidationConfig:
"database_full",
"database_filtered",
"excel_existing",
"excel_full"
"excel_full",
]
if self.data_source not in valid_sources:
errors.append(
@@ -281,6 +289,7 @@ class UIConfig:
def from_env(cls) -> "UIConfig":
"""从环境变量创建配置"""
from config.env_loader import get_env, get_env_int
return cls(
font_family=get_env("UI_FONT_FAMILY", "Microsoft YaHei UI"),
font_size=get_env_int("UI_FONT_SIZE", 10),
@@ -366,19 +375,35 @@ class AppConfig:
"auto_close_browser": self.erp.auto_close_browser,
},
"database": {
"db_type": self.database.db_type if isinstance(self.database.db_type, str) else self.database.db_type.value,
"db_type": (
self.database.db_type
if isinstance(self.database.db_type, str)
else self.database.db_type.value
),
"server": self.database.server,
"database": self.database.database,
"username": self.database.username,
"password": self.database.password,
"sqlserver": {
"driver": self.database.sqlserver.driver if self.database.sqlserver else "ODBC Driver 18 for SQL Server",
"trust_server_certificate": self.database.sqlserver.trust_server_certificate if self.database.sqlserver else "yes",
"driver": (
self.database.sqlserver.driver
if self.database.sqlserver
else "ODBC Driver 18 for SQL Server"
),
"trust_server_certificate": (
self.database.sqlserver.trust_server_certificate
if self.database.sqlserver
else "yes"
),
},
"mysql": {
"host": self.database.mysql.host if self.database.mysql else "",
"port": self.database.mysql.port if self.database.mysql else 3306,
"charset": self.database.mysql.charset if self.database.mysql else "utf8mb4",
"charset": (
self.database.mysql.charset
if self.database.mysql
else "utf8mb4"
),
},
},
"paths": {