🔀 Merge pull request #748

Fix: dict(config) raise error
This commit is contained in:
Ju4tCode 2022-01-27 11:31:05 +08:00 committed by GitHub
commit 1b08e0d822
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -12,9 +12,18 @@ import os
from pathlib import Path
from datetime import timedelta
from ipaddress import IPv4Address
from typing import Any, Set, Dict, Tuple, Union, Mapping, Optional
from typing import (
TYPE_CHECKING,
Any,
Set,
Dict,
Tuple,
Union,
Mapping,
Optional,
)
from pydantic import BaseSettings, IPvAnyAddress, validator
from pydantic import BaseSettings, IPvAnyAddress
from pydantic.env_settings import (
SettingsError,
EnvSettingsSource,
@ -100,6 +109,7 @@ class CustomEnvSettings(EnvSettingsSource):
class BaseConfig(BaseSettings):
if TYPE_CHECKING:
# dummy getattr for pylance checking, actually not used
def __getattr__(self, name: str) -> Any: # pragma: no cover
return self.__dict__.get(name)
@ -149,8 +159,8 @@ class Config(BaseConfig):
配置方法参考: [配置](https://v2.nonebot.dev/docs/tutorial/configuration)
"""
_env_file: str
_common_config: Dict[str, Any]
_env_file: str = ".env"
_common_config: Dict[str, Any] = {}
# nonebot configs
driver: str = "~fastapi"