configuration support both:
- .env file
- settings.toml file
uv
as An extremely fast Python package and project manager, written in Rust.- uv commands:
uv init: Create a new Python project.
uv add: Add a dependency to the project.
uv remove: Remove a dependency from the project.
uv sync: Sync the project's dependencies with the environment.
uv lock: Create a lockfile for the project's dependencies.
uv run: Run a command in the project environment.
uv tree: View the dependency tree for the project.
uv build: Build the project into distribution archives.
uv publish: Publish the project to a package index.
[default]
key = "value"
databases = { default = { url = "postgresql+psycopg://postgres:[email protected]:5432/workspace" } }
pg_url = "postgresql+psycopg://postgres:[email protected]:5432/workspace"
pg_a_url = "postgresql+psycopg_async://postgres:[email protected]:5432/workspace"
[test]
key = "abc"
databases.default.url = "postgresql+psycopg_async://postgres:[email protected]:5432/workspace"
def test_simple_kv():
assert settings.key == "value"
def test_nested_settings():
assert isinstance(settings.databases,dict)
- swith environment to test
- the database default url is changed to test environment, not default value anymore
def test_switch_env_variables():
qpyconf.ensure_env_settings(env_name="test")
assert qpyconf.settings.databases.default.url == "postgresql+psycopg_async://postgres:[email protected]:5432/workspace"
- env file
ENV_EXAMPLE='ENV_EXAMPLE'
- Get this value
def test_env_settings():
print(settings.env_example)
assert settings.env_example=="ENV_EXAMPLE"