Skip to content

Commit 7b72417

Browse files
Fixed lint errors. Configured landscape
1 parent ff9f1c5 commit 7b72417

22 files changed

+57
-48
lines changed

.landscape.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
test-warnings: no
2+
strictness: veryhigh
3+
max-line-length: 120
4+
uses:
5+
- django
6+
7+
pylint:
8+
disable:
9+
- star-args
10+
- too-few-public-methods
11+
- too-many-ancestors

account/forms.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
__author__ = 'dheerendra'
2-
31
from django import forms
42

53

@@ -45,4 +43,4 @@ class LoginForm(forms.Form):
4543
}
4644
),
4745
required=False
48-
)
46+
)

account/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import os
44
from uuid import uuid4
55

6+
67
def user_profile_picture(instance, filename):
78
filename = filename.split('.')
89
if len(filename) > 1:

account/urls.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
__author__ = 'dheerendra'
2-
31
from django.conf.urls import url
42
from .views import LoginView, LogoutView
53

64
urlpatterns = [
75
url(r'^login/$', LoginView.as_view(), name="login"),
86
url(r'^logout/$', LogoutView.as_view(), name='logout'),
9-
]
7+
]

application/forms.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ class RegistrationForm(forms.ModelForm):
99
class Meta:
1010
model = Application
1111
fields = (
12-
'name', 'description', 'logo', 'website', 'privacy_policy', 'client_id', 'client_secret', 'client_type', 'authorization_grant_type',
13-
'redirect_uris')
12+
'name', 'description', 'logo', 'website', 'privacy_policy', 'client_id', 'client_secret', 'client_type',
13+
'authorization_grant_type', 'redirect_uris')
1414
widgets = {
1515
'description': forms.Textarea(
1616
attrs={'class': 'form-control', 'rows': 3, }

application/templatetags/scope.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
from django import template
2-
from django.conf import settings
32
from core.utils import get_default_scopes
43

54
register = template.Library()
65

76

87
@register.filter(name='zip')
9-
def zip_list(a, b):
10-
return list(zip(a, b))
8+
def zip_list(lis1, lis2):
9+
"""
10+
Template tag to zip 2 lists
11+
:param lis1: First List
12+
:param lis2: Second List
13+
:return: Zipped lists
14+
"""
15+
return zip(lis1, lis2)
1116

1217

1318
@register.filter(name='get_basic_scope')

application/urls.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
__author__ = 'dheerendra'
2-
3-
from django.conf.urls import include, url
4-
import oauth2_provider.urls
1+
from django.conf.urls import url
52
from views import ApplicationRegistrationView, ApplicationUpdateView, CustomAuthorizationView
63

74
urlpatterns = [

application/validators.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ def save_bearer_token(self, token, request, *args, **kwargs):
2424
It's messy. It is 90% code from parent function. I didn't find a way to reduce it.
2525
I tried and I failed :'(
2626
Sin Count += 1
27-
"""
2827
29-
"""
28+
3029
Save access and refresh token, If refresh token is issued, remove old refresh tokens as
3130
in rfc:`6`
3231
"""

core/notification.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ def open(self):
3838
return True
3939
except smtplib.SMTPException:
4040
if not self.fail_silently:
41-
raise
41+
raise

core/templatetags/absolute_url.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
@register.simple_tag(takes_context=True)
77
def absolute_url(context, location):
88
request = context['request']
9-
return request.build_absolute_uri(location)
9+
return request.build_absolute_uri(location)

core/templatetags/model_media.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ def model_field_media_url(field):
1212
url = urljoin(settings.MEDIA_URL, url)
1313
except ValueError:
1414
url = None
15-
return url
15+
return url

core/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
def get_default_scopes(application):
55
if application.is_anonymous:
66
return application.required_scopes.split()
7-
return settings.OAUTH2_DEFAULT_SCOPES
7+
return settings.OAUTH2_DEFAULT_SCOPES

gunicorn_conf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
"""gunicorn WSGI server configuration."""
1+
# pylint: disable=invalid-name
22
from multiprocessing import cpu_count
33

44

5-
def max_workers():
5+
def max_workers():
66
return 2 * cpu_count() + 1
77

88

99
workers = max_workers()
1010
worker_class = 'gevent'
1111
accesslog = "logs/gunicorn_access.log"
1212
access_log_format = "%(h)s %({X-Real-IP}i)s %(D)s %(l)s %(u)s %(t)s %(r)s %(s)s %(b)s %(f)s %(a)s"
13-
errorlog = "logs/gunicorn_error.log"
13+
errorlog = "logs/gunicorn_error.log"

sso/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,4 +267,4 @@
267267
}
268268
logging.config.dictConfig(LOGGING)
269269

270-
from settings_user import *
270+
from settings_user import * # noqa

sso/urls.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@
4242
urlpatterns += [
4343
url(r'^%s(?P<path>.*)$' % re.escape(settings.STATIC_URL.lstrip('/')), serve,
4444
kwargs={
45-
'document_root': settings.STATIC_ROOT
45+
'document_root': settings.STATIC_ROOT,
4646
}
4747
),
4848
url(r'^%s(?P<path>.*)$' % re.escape(settings.MEDIA_URL.lstrip('/')), serve,
4949
kwargs={
50-
'document_root': settings.MEDIA_ROOT
50+
'document_root': settings.MEDIA_ROOT,
5151
}
5252
),
5353
]

user_resource/forms.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ class ProfilePictureForm(forms.Form):
88
profile_picture = forms.ImageField()
99

1010
def clean_profile_picture(self):
11-
pp = self.cleaned_data['profile_picture']
12-
content_type = pp.content_type.split('/')[0]
11+
profile_picture = self.cleaned_data['profile_picture']
12+
content_type = profile_picture.content_type.split('/')[0]
1313
if content_type in ['image']:
14-
if pp._size > 5242880:
14+
if profile_picture.size > 5242880:
1515
raise forms.ValidationError(_('Please keep filesize under %s. Current filesize %s') % (
16-
filesizeformat(5242880), filesizeformat(pp._size)))
16+
filesizeformat(5242880), filesizeformat(profile_picture.size)))
1717
else:
1818
raise forms.ValidationError(_('File type is not supported'))
19-
return pp
19+
return profile_picture
2020

2121

2222
class InstituteAddressForm(forms.ModelForm):

user_resource/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,4 @@ class SentMessage(models.Model):
103103
user = models.ForeignKey(User)
104104
status = models.BooleanField(default=True)
105105
error_message = models.TextField(null=True, blank=True)
106-
created = models.DateTimeField(auto_now_add=True)
106+
created = models.DateTimeField(auto_now_add=True)

user_resource/oauth.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
default_fields = ['id', ]
2-
user_fields = [
1+
DEFAULT_FIELDS = ['id', ]
2+
USER_FIELDS = [
33
'username',
44
'first_name',
55
'last_name',
@@ -13,7 +13,7 @@
1313
'roll_number',
1414
]
1515

16-
scope_to_field_map = {
16+
SCOPE_TO_FIELD_MAP = {
1717
'basic': ['id', ],
1818
'profile': ['first_name', 'last_name'],
1919
'picture': ['profile_picture'],

user_resource/serializers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from .models import Program, ContactNumber, SecondaryEmail, InstituteAddress
33
from django.contrib.auth.models import User
44
import copy
5-
from .oauth import default_fields, user_fields
5+
from .oauth import DEFAULT_FIELDS, USER_FIELDS
66

77

88
class ProgramSerializer(serializers.ModelSerializer):
@@ -44,7 +44,7 @@ def __init__(self, *args, **kwargs):
4444
fields = self.context.get('fields')
4545
if not isinstance(fields, list) and not isinstance(fields, set):
4646
fields = []
47-
fields.extend(default_fields)
47+
fields.extend(DEFAULT_FIELDS)
4848

4949
if fields is not None:
5050
allowed = set(fields)
@@ -55,7 +55,7 @@ def __init__(self, *args, **kwargs):
5555

5656
class Meta:
5757
model = User
58-
fields = copy.deepcopy(default_fields).extend(user_fields)
58+
fields = copy.deepcopy(DEFAULT_FIELDS).extend(USER_FIELDS)
5959

6060

6161
class SendMailSerializer(serializers.Serializer):

user_resource/views/api.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from django.core.mail import EmailMessage
1111

1212
from ..serializers import UserSerializer, SendMailSerializer
13-
from ..oauth import scope_to_field_map, default_fields, user_fields
13+
from ..oauth import SCOPE_TO_FIELD_MAP, DEFAULT_FIELDS, USER_FIELDS
1414
from ..models import SentMessage
1515

1616
logger = logging.getLogger(__name__)
@@ -33,15 +33,15 @@ def list(self, request):
3333
granted_scopes = granted_scopes.split()
3434
granted_fields = []
3535
for scope in granted_scopes:
36-
granted_fields.extend(scope_to_field_map[scope])
36+
granted_fields.extend(SCOPE_TO_FIELD_MAP[scope])
3737

3838
if fields is None:
3939
fields = []
4040
else:
4141
fields = fields.split(',')
4242
fields = [field.strip() for field in fields if field.strip()]
4343
fields = set(fields)
44-
all_fields = set(default_fields + user_fields)
44+
all_fields = set(DEFAULT_FIELDS + USER_FIELDS)
4545
undefined_fields = list(fields - all_fields)
4646
if undefined_fields:
4747
error_message = {
@@ -89,10 +89,10 @@ def send_mail(self, request):
8989
email_message.send()
9090
sent_message.status = True
9191
response_data['status'] = True
92-
except SMTPException as e:
92+
except SMTPException as err:
9393
sent_message.status = False,
94-
sent_message.error_message = e.message
95-
logger.error(e)
94+
sent_message.error_message = err.message
95+
logger.error(err)
9696
response_data['status'] = False
9797
sent_message.save()
9898
return Response(response_data)

user_resource/views/home.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ class UpdateUserProfilePicture(LoginRequiredMixin, View):
8484
def post(self, request):
8585
pp_form = ProfilePictureForm(request.POST, request.FILES)
8686
if pp_form.is_valid():
87-
pp = pp_form.cleaned_data['profile_picture']
87+
profile_picture = pp_form.cleaned_data['profile_picture']
8888
userprofile = request.user.userprofile
89-
userprofile.profile_picture = pp
89+
userprofile.profile_picture = profile_picture
9090
userprofile.save()
9191
response = {'url': userprofile.profile_picture.url}
9292
return HttpResponse(json.dumps(response))

widget/urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
urlpatterns = [
66
url(r'login/$', LoginWidget.as_view(), name='login'),
7-
]
7+
]

0 commit comments

Comments
 (0)