Skip to content

[bug] Variables in @format strings don't get overwritten #575

@joshgordon

Description

@joshgordon

Describe the bug
When using @Format to define keys using other variables not in the root of the TOML file (or inside [default]), and overriding the variable being referenced in the @Format string (e.g. by settings environment variables), the original variable gets used.

To Reproduce
Have a config file like this:

INSTALL_DIR = "/opt/myapp"
LOGS_DIR = "@format {this.INSTALL_DIR}/logs"

[ingest]
BASE_PATH = "/opt/ingest"
LOGS_DIR = "@format {this.ingest.BASE_PATH}/logs"

and run a python shell, and override the ingest.BASE_PATH with a different directory:

$ DYNACONF_INGEST__BASE_PATH=/tmp/ingest python
>>> from config import settings
>>> settings.ingest.LOGS_DIR
'/opt/ingest/logs'
>>> settings.ingest.BASE_PATH
'/tmp/ingest'

Because seeing is better than explaining, here's a repl.it that demonstrates the issue.

Expected behavior
The ingest.LOGS_DIR should inherit the new ingest.BASE_PATH brought in from the environment. Instead, it's using the base path as defined in the config file.

Environment (please complete the following information):

  • OS: Centos 7
  • Dynaconf Version: 3.1.4
  • Frameworks in use (Flask, Django? versions..) N/A

Additional context
Git repo of the repl.it available here

Metadata

Metadata

Assignees

Labels

LazyIssueRelated to lazy evaluation such as @format etc...bugduplicate

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions