mirror of
https://github.com/nonebot/nonebot2.git
synced 2026-01-19 02:01:48 +00:00
✨ Feature: 允许插件从环境变量中读取配置项并支持 alias (#3673)
Co-authored-by: Ju4tCode <42488585+yanyongyu@users.noreply.github.com>
This commit is contained in:
@@ -37,6 +37,7 @@ class Example(BaseSettings):
|
||||
complex_union: Union[int, list[int]] = 1
|
||||
nested: Simple = Simple()
|
||||
nested_inner: Simple = Simple()
|
||||
aliased_simple: str = Field(default="", alias="alias_simple")
|
||||
|
||||
|
||||
class ExampleWithoutDelimiter(Example):
|
||||
@@ -85,6 +86,8 @@ def test_config_with_env():
|
||||
with pytest.raises(AttributeError):
|
||||
config.nested_inner__b
|
||||
|
||||
assert config.aliased_simple == "aliased_simple"
|
||||
|
||||
assert config.common_config == "common"
|
||||
|
||||
assert config.other_simple == "simple"
|
||||
|
||||
Reference in New Issue
Block a user