Skip to content

Commit 8af6ca5

Browse files
committed
lint: Blacken all the code
String normalization is done in a separate commit, since it makes the patch unreadable otherwise.
1 parent 9844347 commit 8af6ca5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1954
-1319
lines changed

.pre-commit-config.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,11 @@ repos:
3030
- id: isort
3131
additional_dependencies: [toml]
3232
files: \.py$
33+
34+
- repo: https://github.com/psf/black
35+
rev: stable
36+
hooks:
37+
- id: black
38+
language_version: python3.6
39+
args: [--skip-string-normalization]
40+
exclude: .*/migrations/.*

docs/source/conf.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,5 @@
4444

4545

4646
def setup(app):
47-
app.add_config_value('recommonmark_config', {
48-
'enable_auto_toc_tree': True,
49-
}, True)
47+
app.add_config_value('recommonmark_config', {'enable_auto_toc_tree': True,}, True)
5048
app.add_transform(AutoStructify)

junction/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# -*- coding: utf-8 -*-
22
__version__ = '0.3.2'
3-
__version_info__ = tuple([int(num) if num.isdigit() else num for num in __version__.replace('-', '.', 1).split('.')])
3+
__version_info__ = tuple(
4+
[
5+
int(num) if num.isdigit() else num
6+
for num in __version__.replace('-', '.', 1).split('.')
7+
]
8+
)
49

510
# This will make sure the app is always imported when
611
# Django starts so that shared_task will use this app.

junction/base/admin.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,18 @@ def save_model(self, request, obj, form, change):
1616

1717

1818
class TimeAuditAdmin(admin.ModelAdmin):
19-
list_display = ('created_at', 'modified_at',)
19+
list_display = (
20+
'created_at',
21+
'modified_at',
22+
)
2023

2124

2225
class AuditAdmin(TimeAuditAdmin):
2326
list_display = ('created_by', 'modified_by',) + TimeAuditAdmin.list_display
24-
exclude = ('created_by', 'modified_by',)
27+
exclude = (
28+
'created_by',
29+
'modified_by',
30+
)
2531

2632
def save_model(self, request, obj, form, change):
2733
save_model(self, request, obj, form, change)

junction/base/constants.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66

77
def _user_attributes(cls):
88
defaults = dir(type(str('defaults'), (object,), {})) # gives all inbuilt attrs
9-
return [
10-
item[0] for item in inspect.getmembers(cls) if item[0] not in defaults]
9+
return [item[0] for item in inspect.getmembers(cls) if item[0] not in defaults]
1110

1211

1312
def choices(cls):
@@ -88,15 +87,20 @@ class ConferenceSettingConstants:
8887
ALLOW_PUBLIC_VOTING_ON_PROPOSALS = {
8988
"name": "allow_public_voting_on_proposals",
9089
"value": True,
91-
"description": "Allow public to vote on proposals"}
90+
"description": "Allow public to vote on proposals",
91+
}
9292

93-
DISPLAY_PROPOSALS_IN_PUBLIC = {"name": "display_proposals_in_public",
94-
"value": True,
95-
"description": "Display proposals in public"}
93+
DISPLAY_PROPOSALS_IN_PUBLIC = {
94+
"name": "display_proposals_in_public",
95+
"value": True,
96+
"description": "Display proposals in public",
97+
}
9698

97-
ALLOW_PLUS_ZERO_REVIEWER_VOTE = {"name": "allow_plus_zero_reviewer_vote",
98-
"value": True,
99-
"description": "Allow +0 vote in reviewer votes"}
99+
ALLOW_PLUS_ZERO_REVIEWER_VOTE = {
100+
"name": "allow_plus_zero_reviewer_vote",
101+
"value": True,
102+
"description": "Allow +0 vote in reviewer votes",
103+
}
100104

101105

102106
@choices

junction/base/emailer.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def send_email(to, context, template_dir):
1919
:rtype: None
2020
2121
"""
22+
2223
def to_str(template_name):
2324
return render_to_string(path.join(template_dir, template_name), context).strip()
2425

@@ -28,9 +29,14 @@ def to_str(template_name):
2829
from_email = settings.DEFAULT_FROM_EMAIL
2930
recipient_list = [_format_email(to)]
3031

31-
return send_mail(subject, text_message, from_email, recipient_list, html_message=html_message)
32+
return send_mail(
33+
subject, text_message, from_email, recipient_list, html_message=html_message
34+
)
3235

3336

3437
def _format_email(user):
35-
return user.email if user.first_name and user.last_name else \
36-
'"{} {}" <{}>'.format(user.first_name, user.last_name, user.email)
38+
return (
39+
user.email
40+
if user.first_name and user.last_name
41+
else '"{} {}" <{}>'.format(user.first_name, user.last_name, user.email)
42+
)

junction/base/models.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
class TimeAuditModel(models.Model):
99
"""To track when the record was created and last modified
1010
"""
11+
1112
created_at = models.DateTimeField(auto_now_add=True, verbose_name="Created At")
1213
modified_at = models.DateTimeField(auto_now=True, verbose_name="Last Modified At")
1314

@@ -18,16 +19,26 @@ class Meta:
1819
class UserAuditModel(models.Model):
1920
""" To track who created and last modified the record
2021
"""
21-
created_by = models.ForeignKey(User, related_name='created_%(class)s_set',
22-
null=True, blank=True, verbose_name="Created By")
23-
modified_by = models.ForeignKey(User, related_name='updated_%(class)s_set',
24-
null=True, blank=True, verbose_name="Modified By")
22+
23+
created_by = models.ForeignKey(
24+
User,
25+
related_name='created_%(class)s_set',
26+
null=True,
27+
blank=True,
28+
verbose_name="Created By",
29+
)
30+
modified_by = models.ForeignKey(
31+
User,
32+
related_name='updated_%(class)s_set',
33+
null=True,
34+
blank=True,
35+
verbose_name="Modified By",
36+
)
2537

2638
class Meta:
2739
abstract = True
2840

2941

3042
class AuditModel(TimeAuditModel, UserAuditModel):
31-
3243
class Meta:
3344
abstract = True

junction/base/monkey.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ def patch_urlresolvers():
3737
old_reverse = urlresolvers.reverse
3838

3939
def new_reverse(viewname, urlconf=None, args=None, kwargs=None, current_app=None):
40-
path = old_reverse(viewname, urlconf=urlconf, args=args, kwargs=kwargs,
41-
current_app=current_app)
40+
path = old_reverse(
41+
viewname, urlconf=urlconf, args=args, kwargs=kwargs, current_app=current_app
42+
)
4243
if is_absolute_url(path):
4344
return path
4445

junction/base/templatetags/date.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ def fromnow(value):
1515
A wrapper around arrow.humanize(), returns natural time which is less precise than
1616
django's naturaltime filter. It doesn't display weeks and combination of days & hours.
1717
"""
18-
if not (isinstance(value, date) or isinstance(value, arrow.Arrow)): # datetime is a subclass of date
18+
if not (
19+
isinstance(value, date) or isinstance(value, arrow.Arrow)
20+
): # datetime is a subclass of date
1921
return value
2022

2123
return arrow.get(value).humanize()

junction/base/utils.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,35 @@ def get_date_diff_display(start, end):
77

88
# year are same now
99
if end.month != start.month:
10-
return '%s - %s, %s' % (start.strftime('%-d %b'), end.strftime('%-d %b'), start.year)
10+
return '%s - %s, %s' % (
11+
start.strftime('%-d %b'),
12+
end.strftime('%-d %b'),
13+
start.year,
14+
)
1115

1216
# month and year are same now
1317
if end.day != start.day:
14-
return '%s-%s %s, %s' % (start.strftime('%d'), end.strftime('%d'), start.strftime('%b'), start.year)
18+
return '%s-%s %s, %s' % (
19+
start.strftime('%d'),
20+
end.strftime('%d'),
21+
start.strftime('%b'),
22+
start.year,
23+
)
1524

1625
# day, month and year are same now
1726
if isinstance(start, dt.date):
1827
return '%s' % (start.strftime('%-d %b %Y'))
1928

2029
# am/pm, day, month and year are same now
2130
if end.strftime('%p') != start.strftime('%p'):
22-
return '%s - %s, %s' % (start.strftime('%-I:%M%p'), end.strftime('%-I:%M%p'), start.strftime('%-d %b %Y'))
31+
return '%s - %s, %s' % (
32+
start.strftime('%-I:%M%p'),
33+
end.strftime('%-I:%M%p'),
34+
start.strftime('%-d %b %Y'),
35+
)
2336

24-
return '%s - %s%s' % (start.strftime('%-I:%M'), end.strftime('%-I:%M'), start.strftime('%p, %-d %b %Y'))
37+
return '%s - %s%s' % (
38+
start.strftime('%-I:%M'),
39+
end.strftime('%-I:%M'),
40+
start.strftime('%p, %-d %b %Y'),
41+
)

0 commit comments

Comments
 (0)