-
-
Notifications
You must be signed in to change notification settings - Fork 148
Migrate to django-environ #244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
This patch uses django-environ and drop deprecated and old packages django-cache-url, dj-email-url, dj-database-url and dj-cache-url. Tests are updated according to the behavior of django-environ. Signed-off-by: Chenxiong Qi <[email protected]>
Codecov Report
@@ Coverage Diff @@
## master #244 +/- ##
==========================================
- Coverage 90.08% 89.75% -0.33%
==========================================
Files 27 25 -2
Lines 1210 1201 -9
Branches 101 107 +6
==========================================
- Hits 1090 1078 -12
- Misses 89 90 +1
- Partials 31 33 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
self.assertEqual( | ||
cm.exception.args[0], | ||
"Cannot interpret cache URL value 'redis://user@host:port/1'") | ||
self.assertEqual(cm.exception.args[0], 'wrong') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks "wrong"?!
Shouldn't it have more info / a full msg?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
django-environ simply raises KeyError
when looking up a cache scheme by wrong
, and here assertRaises
catches the KeyError
.
It might be good for django-envion to catch the KeyError and reraise a specific error with more descriptive message.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, I made a patch to django-environ, joke2k/django-environ#235
After this patch is accepted and merged, this assertion could be updated accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tkdchen , that patch was merged; I guess this can be updated now ?
with env(EMAIL_URL='smtps://[email protected]:[email protected]:wrong'): # noqa: E501 | ||
self.assertRaises(ValueError, value.setup, 'TEST') | ||
|
||
def test_cache_url_value(self): | ||
cache_setting = { | ||
'default': { | ||
'BACKEND': 'django_redis.cache.RedisCache', | ||
'LOCATION': 'redis://host:6379/1', | ||
'LOCATION': 'redis://user@host:6379/1', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently it changes some defaults (more secure by default).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if I get your point. Is this change acceptable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It changes defaults apparently, so we should bump the major or at least minor version for it.
tests/test_values.py
Outdated
'EMAIL_USE_TLS': True}) | ||
with env(EMAIL_URL='console://'): | ||
with env(EMAIL_URL='consolemail://'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that change required?
Is it related to https://github.com/psgs/ConsoleMail?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it related to https://github.com/psgs/ConsoleMail?
No. I'm not aware of ConsoleMail. What I learned from django-environ is only consolemail
is defined in email schemes, but no console
. The consolemail
maps to same backend django.core.mail.backends.console.EmailBackend
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's another behavior change then apparently AFAIK.
All those might be fine, and it's good to modernize, but might break setups/configs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @blueyed, I added another commit to make console://
still work in apps using it, and deprecate console://
.
setup.py
Outdated
'django-cache-url>=1.0.0', | ||
'dj-database-url', | ||
'dj-email-url', | ||
'dj-search-url', | ||
'six', | ||
'Sphinx>=1.4', | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could maybe still be in extras_require
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks no need here. How useful to keep those in extra_require?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It avoids having to install / installing it by default when not needed.
I guess the typical usecase is using URLs for configs then, so that seems to be OK.
Apps using schema console:// still works, which is converted to consolemail:// internally in order to work with django-environ. Meanwhile, a deprecation warning is output for console://. Signed-off-by: Chenxiong Qi <[email protected]>
e04768c
to
f376341
Compare
I think |
Hi team / @tkdchen any update on this? It looks like all code review has been addressed. Would be great to get this merged! @pauloxnet What's your reasoning for having
|
Hi folks. Can you see also django/django#13029 and the related mailing list discussion? tl;dr: Maybe we pull something into Django here. Perhaps it makes sense to have env vars read by the default project templates, but we should get right exactly what that should look like, and I don't want us to reinvent something that's already solved™ by the community. It would be good to get your thoughts as contributors here. Thanks 😉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am very positive about this change moves o django-environ. can we just rebase and get this merged
@auvipy It looks like @pauloxnet (who is now helping to maintain this project) objects to this change:
Could we get a consensus before merging this? If you (@auvipy) are planning to merge things yourself, could you please join the maintainer team and communicate your intentions with the rest of us: #295 (comment) @pauloxnet Do you still object to this? It looks like
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@auvipy There are a some issues with your recent merge. See inline comments.
setup.py
Outdated
'testing': [ | ||
'django-discover-runner', | ||
'mock', | ||
'django-cache-url>=1.0.0', | ||
'dj-database-url', | ||
'dj-email-url', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These 4 packages need to be removed from the testing
extra too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docs for these Value types need to be updated too, as they contain references to the old upstream packages: https://github.com/jazzband/django-configurations/blob/master/docs/values.rst#url-based-values
Users looking for precise syntax info should be pointed to django-environ
docs instead.
I'm going to review again this PR but the main guidelines for me is similar to the one used by Django to strongly avoid to depend on other packages, or depend only on trusted, maintained and really necessary ones. |
Co-authored-by: Brian Helba <[email protected]>
Co-authored-by: Brian Helba <[email protected]>
Co-authored-by: Brian Helba <[email protected]>
I just shared my suggestion. but i strongly believe moving to django-environ would a good move. even django core tried that way. |
Also in my humble opinion @pauloxnet reasoning on blocking this is not valid. even if he is maintaining this project he do not have enough contribution history to the project. I am also interested to join the team as well. no offense just sharing my honest thoughts. |
No offense at all, you're totally right, but at the same time I'm using this package in a lot of projects as many other users I think that want their projects continue running. This is PR is a huge changes for this project, it add a totally new dependency and it's not retro compatible. If you really think start using However I think it's a better idea to release the 2.3 version. |
it would be better in a v3.0 release |
I would agree with @pauloxnet on this one and would go a step further by creating an internal URL checker and converter to remove the dependencies on the 3 external packages. I had to fix a unit test that started failing due to a change in dj_database_url |
This patch uses django-environ and drop deprecated and old packages
django-cache-url, dj-email-url, dj-database-url and dj-cache-url.
Tests are updated according to the behavior of django-environ.
Signed-off-by: Chenxiong Qi [email protected]