Skip to content

Commit 4a9b484

Browse files
authored
Merge pull request #36 from edx/azarembok/django2
PROD-1074: Upgrade to django 2.2.
2 parents 07e2451 + 72fce65 commit 4a9b484

24 files changed

Lines changed: 246 additions & 200 deletions

.travis.yml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,29 @@ language: python
55
matrix:
66
include:
77
- python: 2.7
8-
env: TOXENV=py27
8+
env: TOXENV=py27-django111
9+
- python: 3.5
10+
env: TOXENV=py35-django111
11+
- python: 3.5
12+
env: TOXENV=py35-django111
13+
- python: 3.5
14+
env: TOXENV=py35-django20
15+
- python: 3.5
16+
env: TOXENV=py35-django21
17+
- python: 3.5
18+
env: TOXENV=py35-django22
19+
- python: 3.5
20+
env: TOXENV=quality
21+
- python: 3.5
22+
env: TOXENV=docs
923
- python: 3.6
10-
env: TOXENV=py36
24+
env: TOXENV=py36-django111
1125
- python: 3.6
12-
env: TOXENV=quality
26+
env: TOXENV=py36-django20
1327
- python: 3.6
14-
env: TOXENV=docs
28+
env: TOXENV=py36-django21
29+
- python: 3.6
30+
env: TOXENV=py36-django22
1531

1632
cache:
1733
- pip

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ upgrade: ## update the requirements/*.txt files with the latest packages satisfy
4848
pip-compile --upgrade -o requirements/quality.txt requirements/quality.in
4949
pip-compile --upgrade -o requirements/travis.txt requirements/travis.in
5050
pip-compile --upgrade -o requirements/dev.txt requirements/dev.in
51+
# Let tox control the Django version for tests
52+
sed '/^[dD]jango==/d' requirements/test.txt > requirements/test.tmp
53+
mv requirements/test.tmp requirements/test.txt
5154

5255
quality: ## check coding style with pycodestyle and pylint
5356
tox -e quality

code_annotations/__init__.py

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

55
from __future__ import absolute_import, unicode_literals
66

7-
__version__ = '0.3.2'
7+
__version__ = '0.3.3'

code_annotations/base.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,15 @@ def _add_annotation_token(self, token):
130130
self.annotation_tokens.append(token)
131131

132132
def _configure_coverage(self, coverage_target):
133+
"""
134+
Set coverage_target to the specified value.
135+
136+
Args:
137+
coverage_target:
138+
139+
Returns:
140+
141+
"""
133142
if coverage_target:
134143
try:
135144
self.coverage_target = float(coverage_target)
@@ -339,7 +348,7 @@ def _check_results_choices(self, annotation):
339348
"""
340349
# Not a choice type of annotation, nothing to do
341350
if annotation['annotation_token'] not in self.config.choices:
342-
return
351+
return None
343352

344353
token = annotation['annotation_token']
345354
found_valid_choices = []
@@ -366,6 +375,7 @@ def _check_results_choices(self, annotation):
366375
annotation,
367376
'No choices found for "{}". Expected one of {}.'.format(token, self.config.choices[token])
368377
)
378+
return None
369379

370380
def _get_group_children(self):
371381
"""
@@ -394,6 +404,7 @@ def _get_group_for_token(self, token):
394404
for group in self.config.groups:
395405
if token in self.config.groups[group]:
396406
return group
407+
return None
397408

398409
def check_results(self, all_results):
399410
"""
@@ -452,7 +463,7 @@ def check_results(self, all_results):
452463
if token in group_children:
453464
current_group = self._get_group_for_token(token)
454465

455-
if current_group is None: # pragma: no cover
466+
if not current_group: # pragma: no cover
456467
# If we get here there is a problem with check_results' group_children not matching up with
457468
# our config's groups. That puts us in an unknown state, so we should quit.
458469
raise Exception(
@@ -473,7 +484,7 @@ def check_results(self, all_results):
473484
if current_group:
474485
self.errors.append('File finished with an incomplete group {}!'.format(current_group))
475486

476-
return False if self.errors else True
487+
return not self.errors
477488

478489
def _add_annotation_error(self, annotation, message):
479490
"""
@@ -506,7 +517,6 @@ def search(self):
506517
Returns:
507518
Dict of {filename: annotations} for all files with found annotations.
508519
"""
509-
pass # pragma: no cover
510520

511521
def _format_results_for_report(self, all_results):
512522
"""

code_annotations/cli.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Command line interface for code annotation tools.
33
"""
44
import datetime
5+
import sys
56
import traceback
67

78
import click
@@ -18,7 +19,6 @@ def entry_point():
1819
"""
1920
Top level click command for the code annotation tools.
2021
"""
21-
pass
2222

2323

2424
@entry_point.command('django_find_annotations')
@@ -88,13 +88,13 @@ def django_find_annotations(
8888
click.secho("---------------------------------", fg="red")
8989
click.echo("\n".join(searcher.errors))
9090
# If there are any errors, do not continue
91-
exit(-1)
91+
sys.exit(1)
9292
click.echo("Linting passed without errors.")
9393

9494
if coverage:
9595
if not searcher.check_coverage():
9696
# If there are any errors, do not continue
97-
exit(-1)
97+
sys.exit(1)
9898

9999
click.echo("Coverage passed without errors.")
100100

@@ -153,7 +153,7 @@ def static_find_annotations(config_file, source_path, report_path, verbosity, li
153153
click.secho("{} errors:".format(len(searcher.errors)), fg="red")
154154
click.secho("---------------------------------", fg="red")
155155
click.echo("\n".join(searcher.errors))
156-
exit(-1)
156+
sys.exit(1)
157157
click.echo("Linting passed without errors.")
158158

159159
if report:

code_annotations/exceptions.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,3 @@ class ConfigurationException(Exception):
77
"""
88
Exception specific to code annotation configuration problems.
99
"""
10-
11-
pass

code_annotations/find_django.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import re
88
import sys
99

10-
# pylint: disable=ungrouped-imports
1110
import django
1211
import yaml
1312
from django.apps import apps

code_annotations/generate_docs.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@ def __init__(self, config, report_files):
4949
self.group_mapping[token] = group_name
5050

5151
def _add_report_file_to_full_report(self, report_file, report):
52+
"""
53+
Add a specified report file to a report.
54+
55+
Args:
56+
report_file:
57+
report:
58+
59+
Returns:
60+
61+
"""
5262
loaded_report = yaml.safe_load(report_file)
5363

5464
for filename in loaded_report:

code_annotations/helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def fail(msg):
1515
msg: Message to log
1616
"""
1717
click.secho(msg, fg="red")
18-
sys.exit(-1)
18+
sys.exit(1)
1919

2020

2121
class VerboseEcho(object):

pylintrc

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,28 @@
2626
# 1. Edit the pylintrc file in the edx-lint repo at
2727
# https://github.com/edx/edx-lint/blob/master/edx_lint/files/pylintrc
2828
#
29-
# 2. Make a new version of edx_lint, which involves the usual steps of
30-
# incrementing the version number, submitting and reviewing a pull
31-
# request, and updating the edx-lint version reference in this repo.
29+
# 2. install the updated version of edx-lint (in edx-lint):
3230
#
33-
# 3. Install the newer version of edx-lint.
31+
# $ pip install .
3432
#
35-
# 4. Run:
33+
# 3. Run (in edx-lint):
3634
#
35+
# # uses pylintrc_tweaks from edx-lint for linting in edx-lint
36+
# # NOTE: Use Python 3.x, which no longer includes comments in the output file
3737
# $ edx_lint write pylintrc
3838
#
39-
# 5. This will modify the local file. Submit a pull request to get it
39+
# 4. Make a new version of edx_lint, submit and review a pull request with the
40+
# pylintrc update, and after merging, update the edx-lint version by
41+
# creating a new tag in the repo (uses pbr).
42+
#
43+
# 5. In your local repo, install the newer version of edx-lint.
44+
#
45+
# 6. Run:
46+
#
47+
# # uses local pylintrc_tweaks
48+
# $ edx_lint write pylintrc
49+
#
50+
# 7. This will modify the local file. Submit a pull request to get it
4051
# checked in so that others will benefit.
4152
#
4253
#
@@ -53,9 +64,9 @@
5364
#
5465
# ------------------------------
5566
[MASTER]
56-
ignore = migrations
67+
ignore = ,migrations, settings, wsgi.py
5768
persistent = yes
58-
load-plugins = caniusepython3.pylint_checker,edx_lint.pylint,pylint_django,pylint_celery
69+
load-plugins = edx_lint.pylint,pylint_django,pylint_celery
5970

6071
[MESSAGES CONTROL]
6172
enable =
@@ -248,7 +259,6 @@ enable =
248259
too-many-statements,
249260
too-many-boolean-expressions,
250261

251-
ungrouped-imports,
252262
wrong-import-order,
253263
wrong-import-position,
254264
wildcard-import,
@@ -289,11 +299,13 @@ disable =
289299
dict-view-method,
290300
duplicate-code,
291301
execfile-builtin,
302+
feature-toggle-needs-doc,
292303
file-builtin,
293304
filter-builtin-not-iterating,
294305
fixme,
295306
getslice-method,
296307
hex-method,
308+
illegal-waffle-usage,
297309
import-star-module-level,
298310
indexing-exception,
299311
input-builtin,
@@ -335,12 +347,13 @@ disable =
335347
too-many-locals,
336348
too-many-public-methods,
337349
too-many-return-statements,
350+
ungrouped-imports,
338351
unichr-builtin,
339352
unicode-builtin,
340353
unpacking-in-except,
341354
using-cmp-argument,
342355
xrange-builtin,
343-
zip-builtin-not-iterating,
356+
zip-builtin-not-iterating,,invalid-name,useless-object-inheritance
344357

345358
[REPORTS]
346359
output-format = text
@@ -351,7 +364,7 @@ evaluation = 10.0 - ((float(5 * error + warning + refactor + convention) / state
351364
[BASIC]
352365
bad-functions = map,filter,apply,input
353366
module-rgx = (([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
354-
const-rgx = (([A-Z_][A-Z0-9_]*)|(__.*__)|log|urlpatterns)$
367+
const-rgx = (([A-Z_][A-Z0-9_]*)|(__.*__)|log|urlpatterns|logger|User)$
355368
class-rgx = [A-Z_][a-zA-Z0-9]+$
356369
function-rgx = ([a-z_][a-z0-9_]{2,40}|test_[a-z0-9_]+)$
357370
method-rgx = ([a-z_][a-z0-9_]{2,40}|setUp|set[Uu]pClass|tearDown|tear[Dd]ownClass|assert[A-Z]\w*|maxDiff|test_[a-z0-9_]+)$
@@ -367,7 +380,7 @@ docstring-min-length = 5
367380

368381
[FORMAT]
369382
max-line-length = 120
370-
ignore-long-lines = ^\s*(# )?<?https?://\S+>?$
383+
ignore-long-lines = ^\s*(# )?((<?https?://\S+>?)|(\.\. \w+: .*))$
371384
single-line-if-stmt = no
372385
no-space-check = trailing-comma,dict-separator
373386
max-module-lines = 1000
@@ -440,4 +453,4 @@ int-import-graph =
440453
[EXCEPTIONS]
441454
overgeneral-exceptions = Exception
442455

443-
# 6221f5507b1554d42ba7e841083736b0e7ebed77
456+
# 2baa8e2454b99e258f3d547e787ce30ef4557e22

0 commit comments

Comments
 (0)