I am working with Visual Studio Code Python Extension on different projects.
For different projects I need often the same Constants information (passwords, tokens, servernames...). One best practice is to use configuration files (ini, yaml...) to store those constants. If I use those files, there are a lot of libraries to parse the content of the config file and access them via Python Dictionaries. But on that way I find no solution to use autocomplete support in Visual Studio Code for the values which are stored in the config file.
A solution that works is to store the Constants in a config.py module. But that is not the preferred solution, because password etc. should not be stored in a .py file. Especially if you use git for versioning. On the other hand you can't use the constants for other programming languages.
I have also tried dynaconf. It is a good solution, but also does not support autocomplete while coding.
Example
config.yaml
fruits: [apple, banana, orange]
veggie: tomato
mushrooms: champignon
myprogram.py
import yaml
import configparser import ConfigParser
with open("config.yaml) as f:
data = yaml.load(f, Loader=yaml.FullLoader)
# normal solution without autocomplete - that works
myConst = data["fruits"]
# wished solution with autocomplete support
# this works with dynaconf but without autocomplete...
myConst = data.fruits
Does anyone has a solution? Thanks! Patrick