Comments (10)
👍 This will solve my problems with docker and local run
from python-decouple.
from python-decouple.
@henriquebastos in my local machine I use sqlite to develop and on docker use mysql.
in my .env was DB=sqlite.
When I start docker the file .env
"override" the docker environment variables.
from python-decouple.
Christofer, idealy you should use a different/specific .env
file for
every instance, and define defaults (fallbacks) for some options
on
your settings.py
.
.env
is not the project config file (that's the settings.py
). The
.env
is the instance config file.
from python-decouple.
One problem I have is that I use .env
with my local settings during development (eg. DATABASE_URL = mysql://...@localhost /...
) and I also use Docker to run integration tests on my machine. These tests need specific settings provided by envvars (eg. DATABASE_URL = mysql://...@dbserver/...
).
The problem happens when I run the tests in Docker and the .env file appears inside the container. In this case python-decouple
use this file instead of envvars provided.
from python-decouple.
Got it. it make sense to me that decouple
supports the unix style of overriding options
.
Should this also happen with .ini
files?
@osantana can you update a PR with tests?
from python-decouple.
Yes, I can do it.
But this change is backward incompatible, so, it could break something. Is it ok for you?
from python-decouple.
Yes. I understand we're changin the priorities on how decouple
evaluates an option
. Today, for .env
we use environ
as a fallback.
This change will use environ
to override .env
, aligning decouple
with the common unix behavior.
Right now (without actual code), I don't see reasons why we shouldn't do
it. And I'm +1 for that.
About the PR:
- Make sure you adapt/extend the current tests for this new behavior. It
will be easier to review the patch. - Note that decouple should still raise the undefined exception when
(1) anoption
does not exists (either on file and environ) and (2) no
default parameter was passed toconfig
.
Thank you for doing this. :)
from python-decouple.
Just released version 3.0 supporting environment variables overriding config files. This closes #10 and #17.
I've experimented with the RapositoryChain
patch and with inheritance. In the end it felt like yak shaving and I simply made RepositoryEnv
and RepositoryIni
explicitly check on os.environ
.
From this issue we're still pending the path search. I've thought about it and I would be satisfied with an inversion of dependency of the search path on AutoConfig
and Config
.
So by default we could search from the settings.py
path, but users could instantiate their own AutoConfig
or Config
with a specific path, like: config = AutoConfig('my/custom/search/path/')
However, since I've never needed this I wasn't sure this was an actual useful feature.
from python-decouple.
@osantana the main clame of this issue is already on previous version, so I'm closing the issue.
from python-decouple.
Related Issues (20)
- Pycharm and the python-decouple package HOT 2
- Support for multiline strings HOT 9
- Pyright reportGeneralTypeIssues error with cast HOT 1
- Add type hints HOT 1
- Feature request: Cascaded settings files HOT 8
- question Changing settings HOT 2
- Feature Request: Fallback to .env.example HOT 3
- decouple.UndefinedValueError: SECRET_KEY not found. Declare it as envvar or define a default value. HOT 4
- Csv(None) hangs
- Infinite recursion in _find_file on Windows when called via pytest HOT 5
- Cascaded Settings Files
- This bugs me so much - Install name differs from package name causing IDE warnings HOT 1
- Feature idea: optional value HOT 2
- decouple.UndefinedValueError: SECRET_KEY not found. HOT 1
- ENV when use Csv can't be optional HOT 1
- Issue with Environment Variables on AWS Elastic Beanstalk HOT 5
- Issue with typings using Pylance type checking HOT 2
- profiling through environment variables HOT 1
- Issues with installation using pipenv HOT 2
- Installation with Poetry give back an error HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-decouple.