mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-02-20 09:38:23 +08:00
commit
1b08e0d822
@ -12,9 +12,18 @@ import os
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from ipaddress import IPv4Address
|
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 (
|
from pydantic.env_settings import (
|
||||||
SettingsError,
|
SettingsError,
|
||||||
EnvSettingsSource,
|
EnvSettingsSource,
|
||||||
@ -100,9 +109,10 @@ class CustomEnvSettings(EnvSettingsSource):
|
|||||||
|
|
||||||
|
|
||||||
class BaseConfig(BaseSettings):
|
class BaseConfig(BaseSettings):
|
||||||
# dummy getattr for pylance checking, actually not used
|
if TYPE_CHECKING:
|
||||||
def __getattr__(self, name: str) -> Any: # pragma: no cover
|
# dummy getattr for pylance checking, actually not used
|
||||||
return self.__dict__.get(name)
|
def __getattr__(self, name: str) -> Any: # pragma: no cover
|
||||||
|
return self.__dict__.get(name)
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -149,8 +159,8 @@ class Config(BaseConfig):
|
|||||||
配置方法参考: [配置](https://v2.nonebot.dev/docs/tutorial/configuration)
|
配置方法参考: [配置](https://v2.nonebot.dev/docs/tutorial/configuration)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
_env_file: str
|
_env_file: str = ".env"
|
||||||
_common_config: Dict[str, Any]
|
_common_config: Dict[str, Any] = {}
|
||||||
|
|
||||||
# nonebot configs
|
# nonebot configs
|
||||||
driver: str = "~fastapi"
|
driver: str = "~fastapi"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user