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
Fix various deprecation warnings #2222
Conversation
src/oscar/core/compat.py
Outdated
if django.VERSION >= (1, 10): | ||
return user.is_authenticated | ||
else: | ||
return user_is_authenticated(user) |
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.
Shouldn't this be return user.is_authenticated()
? This will trigger an infinite loop.
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.
Yeah, search-and-replace gone wrong. Thanks :-)
Codecov Report@@ Coverage Diff @@
## master #2222 +/- ##
==========================================
+ Coverage 81.82% 81.87% +0.04%
==========================================
Files 326 326
Lines 15569 15604 +35
==========================================
+ Hits 12740 12775 +35
Misses 2829 2829
Continue to review full report at Codecov.
|
if id: | ||
yield id | ||
with open(self.filepath, 'r') as fh: | ||
for line in fh.readlines(): |
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.
readlines()
loads the entire contents of the file into memory. I think it's better to just loop over the file object itself: for line in fh
which is memory-efficient.
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.
Fixed
tests/settings.py
Outdated
'django.contrib.sessions.middleware.SessionMiddleware', | ||
'django.middleware.csrf.CsrfViewMiddleware', | ||
'django.contrib.auth.middleware.AuthenticationMiddleware', | ||
'django.contrib.auth.middleware.SessionAuthenticationMiddleware', |
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.
SessionAuthenticationMiddleware
no longer does anything and is removed in Django 2.0 - can remove it from here.
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.
Removed, thanks
Latter one is deprecated
Since 1.10 these are properties on the user instead of methods. The functions are for compat between 1.8+ and 1.10+
This fixes a DeprecationWarning
Instead use `for line in fh` since that is less memory intensive
8626b17
to
534d1a6
Compare
…rnings Fix various deprecation warnings
Would be good to get this in before 1.4.
It fixes the following (1500) deprecation warnings:
It also ignores warnings in django-webtest and sorl, see setup.cfg
The last few should be fixed by #2157 (django-tables2)