Skip to content

Dotted key in YAML settings file #718

@benbouillet

Description

@benbouillet

Hello,

I work on a project where YAML is mandatory for configuration. In the settings.yaml file, we have some keys that includes . (dot) , but Dynaconf interprets it as a variables separator.

- python=3.9.7
- dynaconf=3.1.7

# settings.yaml
default:
 www.google.com: true
from dynaconf import Dynaconf
import yaml

settings = Dynaconf(
    settings_files=["config/settings.yaml"],
    environments=True,
)

print(yaml.dump(settings.as_dict(), sort_keys=False, default_flow_style=False))

returns

WWW:
  GOOGLE:
    COM: true

I know that if we use the .set method, we can have a work-around :

settings.set("www.google.com", True, dotted_lookup=False)

Returns:

WWW.GOOGLE.COM: true

But I can't see a way to apply this dotted_lookup parameter to the YAML core loader.
I tried with simple & double quotes, also with escaping (\.), but without success.

Potential related issue #685

Can you help please ?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions