Skip to content

Commit

Permalink
Merge pull request #96 from edx/iamsobanjaved/python38
Browse files Browse the repository at this point in the history
BOM-1543: Added python 3.8 in test matrix
  • Loading branch information
iamsobanjaved authored Jun 16, 2020
2 parents b434d89 + 4766bc3 commit c3aa3eb
Show file tree
Hide file tree
Showing 23 changed files with 132 additions and 177 deletions.
18 changes: 1 addition & 17 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,9 @@ python:
- 3.5

envs:
- TOXENV=django111
- TOXENV=django20
- TOXENV=django21
- TOXENV=django22
- TOXENV=quality

matrix:
include:
- python: 2.7
env: TOXENV=quality
- python: 2.7
env: TOXENV=django111
- python: 3.6
env: TOXENV=django22
- python: 3.7
env: TOXENV=django22
- python: 3.8
env: TOXENV=django22

addons:
apt:
packages:
Expand Down Expand Up @@ -56,4 +40,4 @@ deploy:
on:
tags: true
python: 3.5
condition: '$TOXENV = django111'
condition: '$TOXENV = django22'
3 changes: 2 additions & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ coverage:
default:
enabled: yes
target: auto
threshold: 0.5
patch:
default:
enabled: yes
target: 100%
target: 97%

comment: false
11 changes: 6 additions & 5 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
#
# make upgrade
#
django==1.11.29 # via -r requirements/base.in, event-tracking
django==2.2.13 # via -r requirements/base.in, event-tracking
elasticsearch==1.9.0 # via -r requirements/base.in
event-tracking==0.3.0 # via -r requirements/base.in
event-tracking==0.3.2 # via -r requirements/base.in
pymongo==3.10.1 # via event-tracking
pytz==2019.3 # via django, event-tracking
six==1.14.0 # via -r requirements/base.in, event-tracking
urllib3==1.25.8 # via elasticsearch
pytz==2020.1 # via django, event-tracking
six==1.15.0 # via -r requirements/base.in, event-tracking
sqlparse==0.3.1 # via django
urllib3==1.25.9 # via elasticsearch
10 changes: 8 additions & 2 deletions requirements/constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,11 @@
# pin when possible. Writing an issue against the offending project and
# linking to it here is good.

# This packages is a backport which can only be installed on Python 2.7
futures ; python_version == "2.7"
# ddt >= 1.4.0 causing test failures
ddt < 1.4.0

# newer version is causing failure
tox-battery==0.5.2


coverage<5.1
65 changes: 30 additions & 35 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,56 +4,51 @@
#
# make upgrade
#
appdirs==1.4.3 # via -r requirements/travis.txt, virtualenv
astroid==1.6.6 # via -r requirements/quality.txt, pylint, pylint-celery
backports.functools-lru-cache==1.6.1 # via -r requirements/quality.txt, astroid, isort, pylint
certifi==2019.11.28 # via -r requirements/travis.txt, requests
appdirs==1.4.4 # via -r requirements/travis.txt, virtualenv
astroid==2.3.3 # via -r requirements/quality.txt, pylint, pylint-celery
certifi==2020.4.5.2 # via -r requirements/travis.txt, requests
chardet==3.0.4 # via -r requirements/travis.txt, requests
click-log==0.3.2 # via -r requirements/quality.txt, edx-lint
click==7.1.1 # via -r requirements/pip-tools.txt, -r requirements/quality.txt, click-log, edx-lint, pip-tools
codecov==2.0.22 # via -r requirements/travis.txt
configparser==4.0.2 # via -r requirements/quality.txt, -r requirements/travis.txt, importlib-metadata, pylint
contextlib2==0.6.0.post1 # via -r requirements/travis.txt, importlib-metadata, importlib-resources, virtualenv, zipp
coverage==5.0.4 # via -r requirements/quality.txt, -r requirements/testing.txt, -r requirements/travis.txt, codecov
ddt==1.3.1 # via -r requirements/quality.txt, -r requirements/testing.txt
click==7.1.2 # via -r requirements/pip-tools.txt, -r requirements/quality.txt, click-log, edx-lint, pip-tools
codecov==2.1.4 # via -r requirements/travis.txt
coverage==5.0.4 # via -c requirements/constraints.txt, -r requirements/quality.txt, -r requirements/testing.txt, -r requirements/travis.txt, codecov
ddt==1.3.1 # via -c requirements/constraints.txt, -r requirements/quality.txt, -r requirements/testing.txt
distlib==0.3.0 # via -r requirements/travis.txt, virtualenv
django==1.11.29 # via -r requirements/quality.txt, -r requirements/testing.txt, event-tracking
django==2.2.13 # via -r requirements/quality.txt, -r requirements/testing.txt, event-tracking
edx-lint==1.4.1 # via -r requirements/quality.txt
elasticsearch==1.9.0 # via -r requirements/quality.txt, -r requirements/testing.txt
enum34==1.1.10 # via -r requirements/quality.txt, astroid
event-tracking==0.3.0 # via -r requirements/quality.txt, -r requirements/testing.txt
event-tracking==0.3.2 # via -r requirements/quality.txt, -r requirements/testing.txt
filelock==3.0.12 # via -r requirements/travis.txt, tox, virtualenv
funcsigs==1.0.2 # via -r requirements/quality.txt, -r requirements/testing.txt, mock
futures==3.3.0 ; python_version == "2.7" # via -c requirements/constraints.txt, -r requirements/quality.txt, isort
idna==2.9 # via -r requirements/travis.txt, requests
importlib-metadata==1.6.0 # via -r requirements/travis.txt, importlib-resources, pluggy, tox, virtualenv
importlib-resources==1.4.0 # via -r requirements/travis.txt, virtualenv
importlib-metadata==1.6.1 # via -r requirements/travis.txt, importlib-resources, pluggy, tox, virtualenv
importlib-resources==1.5.0 # via -r requirements/travis.txt, virtualenv
isort==4.3.21 # via -r requirements/quality.txt, pylint
lazy-object-proxy==1.4.3 # via -r requirements/quality.txt, astroid
mccabe==0.6.1 # via -r requirements/quality.txt, pylint
mock==3.0.5 # via -r requirements/quality.txt, -r requirements/testing.txt
packaging==20.3 # via -r requirements/travis.txt, tox
pathlib2==2.3.5 # via -r requirements/travis.txt, importlib-metadata, importlib-resources, virtualenv
pip-tools==4.5.1 # via -r requirements/pip-tools.txt
packaging==20.4 # via -r requirements/travis.txt, tox
pip-tools==5.2.1 # via -r requirements/pip-tools.txt
pluggy==0.13.1 # via -r requirements/travis.txt, tox
py==1.8.1 # via -r requirements/travis.txt, tox
pycodestyle==2.5.0 # via -r requirements/quality.txt
pycodestyle==2.6.0 # via -r requirements/quality.txt
pylint-celery==0.3 # via -r requirements/quality.txt, edx-lint
pylint-django==0.11.1 # via -r requirements/quality.txt, edx-lint
pylint-django==2.0.11 # via -r requirements/quality.txt, edx-lint
pylint-plugin-utils==0.6 # via -r requirements/quality.txt, pylint-celery, pylint-django
pylint==1.9.5 # via -r requirements/quality.txt, edx-lint, pylint-celery, pylint-django, pylint-plugin-utils
pylint==2.4.2 # via -r requirements/quality.txt, edx-lint, pylint-celery, pylint-django, pylint-plugin-utils
pymongo==3.10.1 # via -r requirements/quality.txt, -r requirements/testing.txt, event-tracking
pyparsing==2.4.6 # via -r requirements/travis.txt, packaging
pytz==2019.3 # via -r requirements/quality.txt, -r requirements/testing.txt, django, event-tracking
pyparsing==2.4.7 # via -r requirements/travis.txt, packaging
pytz==2020.1 # via -r requirements/quality.txt, -r requirements/testing.txt, django, event-tracking
requests==2.23.0 # via -r requirements/travis.txt, codecov
scandir==1.10.0 # via -r requirements/travis.txt, pathlib2
singledispatch==3.4.0.3 # via -r requirements/quality.txt, -r requirements/travis.txt, astroid, importlib-resources, pylint
six==1.14.0 # via -r requirements/pip-tools.txt, -r requirements/quality.txt, -r requirements/testing.txt, -r requirements/travis.txt, astroid, edx-lint, event-tracking, mock, packaging, pathlib2, pip-tools, pylint, singledispatch, tox, virtualenv
toml==0.10.0 # via -r requirements/travis.txt, tox
tox-battery==0.5.2 # via -r requirements/travis.txt
tox==3.14.6 # via -r requirements/travis.txt, tox-battery
typing==3.7.4.1 # via -r requirements/travis.txt, importlib-resources
urllib3==1.25.8 # via -r requirements/quality.txt, -r requirements/testing.txt, -r requirements/travis.txt, elasticsearch, requests
virtualenv==20.0.15 # via -r requirements/travis.txt, tox
wrapt==1.12.1 # via -r requirements/quality.txt, astroid
six==1.15.0 # via -r requirements/pip-tools.txt, -r requirements/quality.txt, -r requirements/testing.txt, -r requirements/travis.txt, astroid, edx-lint, event-tracking, mock, packaging, pip-tools, tox, virtualenv
sqlparse==0.3.1 # via -r requirements/quality.txt, -r requirements/testing.txt, django
toml==0.10.1 # via -r requirements/travis.txt, tox
tox-battery==0.5.2 # via -c requirements/constraints.txt, -r requirements/travis.txt
tox==3.15.2 # via -r requirements/travis.txt, tox-battery
typed-ast==1.4.1 # via -r requirements/quality.txt, astroid
urllib3==1.25.9 # via -r requirements/quality.txt, -r requirements/testing.txt, -r requirements/travis.txt, elasticsearch, requests
virtualenv==20.0.21 # via -r requirements/travis.txt, tox
wrapt==1.11.2 # via -r requirements/quality.txt, astroid
zipp==1.2.0 # via -r requirements/travis.txt, importlib-metadata, importlib-resources

# The following packages are considered to be unsafe in a requirements file:
# pip
9 changes: 6 additions & 3 deletions requirements/pip-tools.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
#
# make upgrade
#
click==7.1.1 # via pip-tools
pip-tools==4.5.1 # via -r requirements/pip-tools.in
six==1.14.0 # via pip-tools
click==7.1.2 # via pip-tools
pip-tools==5.2.1 # via -r requirements/pip-tools.in
six==1.15.0 # via pip-tools

# The following packages are considered to be unsafe in a requirements file:
# pip
34 changes: 15 additions & 19 deletions requirements/quality.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,28 @@
#
# make upgrade
#
astroid==1.6.6 # via pylint, pylint-celery
backports.functools-lru-cache==1.6.1 # via astroid, isort, pylint
astroid==2.3.3 # via pylint, pylint-celery
click-log==0.3.2 # via edx-lint
click==7.1.1 # via click-log, edx-lint
configparser==4.0.2 # via pylint
coverage==5.0.4 # via -r requirements/quality.in, -r requirements/testing.txt
ddt==1.3.1 # via -r requirements/testing.txt
django==1.11.29 # via -r requirements/testing.txt, event-tracking
click==7.1.2 # via click-log, edx-lint
coverage==5.0.4 # via -c requirements/constraints.txt, -r requirements/quality.in, -r requirements/testing.txt
ddt==1.3.1 # via -c requirements/constraints.txt, -r requirements/testing.txt
django==2.2.13 # via -r requirements/testing.txt, event-tracking
edx-lint==1.4.1 # via -r requirements/quality.in
elasticsearch==1.9.0 # via -r requirements/testing.txt
enum34==1.1.10 # via astroid
event-tracking==0.3.0 # via -r requirements/testing.txt
funcsigs==1.0.2 # via -r requirements/testing.txt, mock
futures==3.3.0 ; python_version == "2.7" # via -c requirements/constraints.txt, isort
event-tracking==0.3.2 # via -r requirements/testing.txt
isort==4.3.21 # via pylint
lazy-object-proxy==1.4.3 # via astroid
mccabe==0.6.1 # via pylint
mock==3.0.5 # via -r requirements/testing.txt
pycodestyle==2.5.0 # via -r requirements/quality.in
pycodestyle==2.6.0 # via -r requirements/quality.in
pylint-celery==0.3 # via edx-lint
pylint-django==0.11.1 # via edx-lint
pylint-django==2.0.11 # via edx-lint
pylint-plugin-utils==0.6 # via pylint-celery, pylint-django
pylint==1.9.5 # via edx-lint, pylint-celery, pylint-django, pylint-plugin-utils
pylint==2.4.2 # via edx-lint, pylint-celery, pylint-django, pylint-plugin-utils
pymongo==3.10.1 # via -r requirements/testing.txt, event-tracking
pytz==2019.3 # via -r requirements/testing.txt, django, event-tracking
singledispatch==3.4.0.3 # via astroid, pylint
six==1.14.0 # via -r requirements/testing.txt, astroid, edx-lint, event-tracking, mock, pylint, singledispatch
urllib3==1.25.8 # via -r requirements/testing.txt, elasticsearch
wrapt==1.12.1 # via astroid
pytz==2020.1 # via -r requirements/testing.txt, django, event-tracking
six==1.15.0 # via -r requirements/testing.txt, astroid, edx-lint, event-tracking, mock
sqlparse==0.3.1 # via -r requirements/testing.txt, django
typed-ast==1.4.1 # via astroid
urllib3==1.25.9 # via -r requirements/testing.txt, elasticsearch
wrapt==1.11.2 # via astroid
14 changes: 7 additions & 7 deletions requirements/testing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
#
# make upgrade
#
coverage==5.0.4 # via -r requirements/testing.in
ddt==1.3.1 # via -r requirements/testing.in
coverage==5.0.4 # via -c requirements/constraints.txt, -r requirements/testing.in
ddt==1.3.1 # via -c requirements/constraints.txt, -r requirements/testing.in
elasticsearch==1.9.0 # via -r requirements/base.txt
event-tracking==0.3.0 # via -r requirements/base.txt
funcsigs==1.0.2 # via mock
event-tracking==0.3.2 # via -r requirements/base.txt
mock==3.0.5 # via -r requirements/testing.in
pymongo==3.10.1 # via -r requirements/base.txt, event-tracking
pytz==2019.3 # via -r requirements/base.txt, django, event-tracking
six==1.14.0 # via -r requirements/base.txt, event-tracking, mock
urllib3==1.25.8 # via -r requirements/base.txt, elasticsearch
pytz==2020.1 # via -r requirements/base.txt, django, event-tracking
six==1.15.0 # via -r requirements/base.txt, event-tracking, mock
sqlparse==0.3.1 # via -r requirements/base.txt, django
urllib3==1.25.9 # via -r requirements/base.txt, elasticsearch
34 changes: 14 additions & 20 deletions requirements/travis.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,25 @@
#
# make upgrade
#
appdirs==1.4.3 # via virtualenv
certifi==2019.11.28 # via requests
appdirs==1.4.4 # via virtualenv
certifi==2020.4.5.2 # via requests
chardet==3.0.4 # via requests
codecov==2.0.22 # via -r requirements/travis.in
configparser==4.0.2 # via importlib-metadata
contextlib2==0.6.0.post1 # via importlib-metadata, importlib-resources, virtualenv, zipp
coverage==5.0.4 # via codecov
codecov==2.1.4 # via -r requirements/travis.in
coverage==5.0.4 # via -c requirements/constraints.txt, codecov
distlib==0.3.0 # via virtualenv
filelock==3.0.12 # via tox, virtualenv
idna==2.9 # via requests
importlib-metadata==1.6.0 # via importlib-resources, pluggy, tox, virtualenv
importlib-resources==1.4.0 # via virtualenv
packaging==20.3 # via tox
pathlib2==2.3.5 # via importlib-metadata, importlib-resources, virtualenv
importlib-metadata==1.6.1 # via importlib-resources, pluggy, tox, virtualenv
importlib-resources==1.5.0 # via virtualenv
packaging==20.4 # via tox
pluggy==0.13.1 # via tox
py==1.8.1 # via tox
pyparsing==2.4.6 # via packaging
pyparsing==2.4.7 # via packaging
requests==2.23.0 # via codecov
scandir==1.10.0 # via pathlib2
singledispatch==3.4.0.3 # via importlib-resources
six==1.14.0 # via packaging, pathlib2, tox, virtualenv
toml==0.10.0 # via tox
tox-battery==0.5.2 # via -r requirements/travis.in
tox==3.14.6 # via -r requirements/travis.in, tox-battery
typing==3.7.4.1 # via importlib-resources
urllib3==1.25.8 # via requests
virtualenv==20.0.15 # via tox
six==1.15.0 # via packaging, tox, virtualenv
toml==0.10.1 # via tox
tox-battery==0.5.2 # via -c requirements/constraints.txt, -r requirements/travis.in
tox==3.15.2 # via -r requirements/travis.in, tox-battery
urllib3==1.25.9 # via requests
virtualenv==20.0.21 # via tox
zipp==1.2.0 # via importlib-metadata, importlib-resources
2 changes: 0 additions & 2 deletions search/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ def course_discovery_facets():

class NoSearchEngineError(Exception):
""" NoSearchEngineError exception to be thrown if no search engine is specified """
pass


class QueryParseError(Exception):
Expand All @@ -36,7 +35,6 @@ class QueryParseError(Exception):
error message to the user.
"""
pass


def perform_search(
Expand Down
12 changes: 4 additions & 8 deletions search/elastic.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,10 +538,7 @@ def search(self,

# We have a query string, search all fields for matching text within the "content" node
if query_string:
if six.PY2:
query_string = query_string.encode('utf-8').translate(None, RESERVED_CHARACTERS)
else:
query_string = query_string.translate(query_string.maketrans('', '', RESERVED_CHARACTERS))
query_string = query_string.translate(query_string.maketrans('', '', RESERVED_CHARACTERS))
elastic_queries.append({
"query_string": {
"fields": ["content.*"],
Expand Down Expand Up @@ -610,9 +607,8 @@ def search(self,
if 'QueryParsingException' in message:
log.exception("Malformed search query: %s", message) # lint-amnesty, pylint: disable=unicode-format-string
raise QueryParseError('Malformed search query.')
else:
# log information and re-raise
log.exception("error while searching index - %s", str(message)) # lint-amnesty, pylint: disable=unicode-format-string
raise
# log information and re-raise
log.exception("error while searching index - %s", str(message)) # lint-amnesty, pylint: disable=unicode-format-string
raise

return _translate_hits(es_response)
2 changes: 1 addition & 1 deletion search/filter_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from .utils import _load_class, DateRange


class SearchFilterGenerator(object):
class SearchFilterGenerator:

"""
Class to provide a set of filters for the search.
Expand Down
3 changes: 1 addition & 2 deletions search/initializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from .utils import _load_class


class SearchInitializer(object):
class SearchInitializer:

"""
Class to set starting environment parameters for search app.
Expand All @@ -17,7 +17,6 @@ class SearchInitializer(object):
# pylint: disable=unused-argument, no-self-use
def initialize(self, **kwargs):
""" empty base implementation """
pass

@classmethod
def set_search_enviroment(cls, **kwargs):
Expand Down
15 changes: 3 additions & 12 deletions search/result_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
log = logging.getLogger(__name__) # pylint: disable=invalid-name


class SearchResultProcessor(object):
class SearchResultProcessor:

"""
Class to post-process a search result from the search.
Expand Down Expand Up @@ -81,7 +81,7 @@ def has_match(string):
def decorate_matches(match_in, match_word):
""" decorate the matches within the excerpt """
matches = re.finditer(match_word, match_in, re.IGNORECASE)
for matched_string in set([match.group() for match in matches]):
for matched_string in {match.group() for match in matches}:
match_in = match_in.replace(
matched_string,
getattr(settings, "SEARCH_MATCH_DECORATION", u"<b>{}</b>").format(matched_string)
Expand Down Expand Up @@ -132,16 +132,7 @@ def excerpt(self):
return None

match_phrases = [self._match_phrase]
if six.PY2:
separate_phrases = [
phrase.decode('utf-8')
for phrase in shlex.split(self._match_phrase.encode('utf-8'))
]
else:
separate_phrases = [
phrase
for phrase in shlex.split(self._match_phrase)
]
separate_phrases = list(shlex.split(self._match_phrase))
if len(separate_phrases) > 1:
match_phrases.extend(separate_phrases)
else:
Expand Down
Loading

0 comments on commit c3aa3eb

Please sign in to comment.