(cls, v)
| 783 | @field_validator('database_url', mode='before') |
| 784 | @classmethod |
| 785 | def validate_database_url(cls, v): |
| 786 | if isinstance(v, str): |
| 787 | if v.startswith(("postgres://", "postgresql://")): |
| 788 | return _normalize_database_url(v) |
| 789 | if v.startswith(("postgresql+psycopg://", "postgresql+psycopg2://")): |
| 790 | return v |
| 791 | if isinstance(v, str) and v.startswith("sqlite:///"): |
| 792 | return v |
| 793 | if isinstance(v, str) and not v.startswith(("sqlite:///", "postgresql://", "postgresql+psycopg://", "postgresql+psycopg2://", "mysql://")): |
| 794 | # 如果是文件路径,转换为 SQLite URL |
| 795 | if os.path.isabs(v) or ":/" not in v: |
| 796 | return f"sqlite:///{v}" |
| 797 | return v |
| 798 | |
| 799 | # Web UI 配置 |
| 800 | webui_host: str = "0.0.0.0" |
nothing calls this directly
no test coverage detected