Skip to content

Commit

Permalink
Merge pull request #12 from edx/jenkins/cleanup-python-code-de897e3
Browse files Browse the repository at this point in the history
Python Code Cleanup
  • Loading branch information
awais786 authored Jan 19, 2021
2 parents de897e3 + ab0a674 commit 051587b
Show file tree
Hide file tree
Showing 14 changed files with 88 additions and 111 deletions.
11 changes: 5 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
language: python
python:
- 3.5
- 3.8
- '3.8'
install:
- pip install -r requirements/travis.txt
- pip install -r requirements/travis.txt
script:
- tox
- tox
after_success:
- codecov
- codecov
deploy:
provider: pypi
distributions: sdist bdist_wheel
Expand All @@ -16,4 +15,4 @@ deploy:
secure: jIYzuroblLNT6jdpfhL4+U01fKGTzuXmO68aNuCH+0+Ijyma/wndnk7k1vcD/5CpPua7xw2c5irRhqEVIIKthkot48Jfk25vKPp9Mn89GYGH2lfJnrGTxUnILRU0XgFPSNpNBGQ3EnuH7PfAzjxMTiwxOk+snaAVcz2nyxP3/rHR6wOx7bNqZh79ImzD4UT5TefeZzPdB92MFj1nXGR22F7qoYfKJJsa/2RjqY6XdL+mMrK4u4ZopeBm89SAB8PTDAd+BF52dp0ZufoNwOQGcfkXHPeEV0JWlSvBB/aiB4NijmGmTVniGxWwV4i5HC44O7jhYTvAtrMJE5jjdJYUzOUpwJ4+OXvuaALJGMLc1uMXNvs+4cDZXF2iTg2Cf73cm5zvDMVJn0J7BwUPxOmonMBidpTZaiC2pEokyXXEU+99fL/IvKPtB3FJZIWpOGngWMfPOBRHwxOdwjOrEawUQ8VYIFYFRtEK541q60JDJs7Qfle69b5UpzgtxDDbLVTKNedia9uQ0yxC1VKMQslEmQrp7chG0cLw1sxM45D63P9BePItosnT0dMxY2n3DGo7z68Y4T8gpt+8ZFzfxtwgD4AUyENjwkdr3g791tsE70HJAi7GyexwX2EtMAkxhc6QBtLZq0LVnTG7E110Pcsf8zvI+qaSzZOjamFL261Tvfs=
on:
tags: true
python: 3.5
python: 3.8
15 changes: 7 additions & 8 deletions docs/conf.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# user_util documentation build configuration file, created by
# sphinx-quickstart on Fri Jun 9 13:47:02 2017.
Expand Down Expand Up @@ -47,9 +46,9 @@
master_doc = 'index'

# General information about the project.
project = u'Open edX User Utilities'
copyright = u"2018, J Eskew"
author = u"J Eskew"
project = 'Open edX User Utilities'
copyright = "2018, J Eskew"
author = "J Eskew"

# The version info for the project you're documenting, acts as replacement
# for |version| and |release|, also used in various other places throughout
Expand Down Expand Up @@ -129,8 +128,8 @@
# [howto, manual, or own class]).
latex_documents = [
(master_doc, 'user_util.tex',
u'Open edX User Utilities Documentation',
u'J Eskew', 'manual'),
'Open edX User Utilities Documentation',
'J Eskew', 'manual'),
]


Expand All @@ -140,7 +139,7 @@
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'user_util',
u'Open edX User Utilities Documentation',
'Open edX User Utilities Documentation',
[author], 1)
]

Expand All @@ -152,7 +151,7 @@
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'user_util',
u'Open edX User Utilities Documentation',
'Open edX User Utilities Documentation',
author,
'user_util',
'One line description of project.',
Expand Down
7 changes: 2 additions & 5 deletions requirements/constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,5 @@

# TODO: Many pinned dependencies should be unpinned and/or moved to this constraints file.

# Use latest Django LTS version
Django<2.3.0

# mock version 4.0.0 drops support for python 3.5
mock<4.0.0
# This file contains all common constraints for edx-repos
-c https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt
21 changes: 10 additions & 11 deletions requirements/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,29 @@
# make upgrade
#
alabaster==0.7.12 # via sphinx
babel==2.8.0 # via sphinx
certifi==2020.4.5.1 # via requests
chardet==3.0.4 # via requests
babel==2.9.0 # via sphinx
certifi==2020.12.5 # via requests
chardet==4.0.0 # via requests
click==7.1.2 # via -r requirements/base.in
docutils==0.16 # via sphinx
idna==2.9 # via requests
idna==2.10 # via requests
imagesize==1.2.0 # via sphinx
jinja2==2.11.2 # via sphinx
markupsafe==1.1.1 # via jinja2
packaging==20.3 # via sphinx
pygments==2.6.1 # via sphinx
packaging==20.8 # via sphinx
pygments==2.7.4 # via sphinx
pyparsing==2.4.7 # via packaging
pytz==2020.1 # via babel
requests==2.23.0 # via sphinx
six==1.14.0 # via packaging
pytz==2020.5 # via babel
requests==2.25.1 # via sphinx
snowballstemmer==2.0.0 # via sphinx
sphinx==3.0.3 # via -r requirements/doc.in
sphinx==3.4.3 # via -r requirements/doc.in
sphinxcontrib-applehelp==1.0.2 # via sphinx
sphinxcontrib-devhelp==1.0.2 # via sphinx
sphinxcontrib-htmlhelp==1.0.3 # via sphinx
sphinxcontrib-jsmath==1.0.1 # via sphinx
sphinxcontrib-qthelp==1.0.3 # via sphinx
sphinxcontrib-serializinghtml==1.1.4 # via sphinx
urllib3==1.25.9 # via requests
urllib3==1.26.2 # via requests

# The following packages are considered to be unsafe in a requirements file:
# setuptools
3 changes: 1 addition & 2 deletions requirements/pip_tools.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
# make upgrade
#
click==7.1.2 # via pip-tools
pip-tools==5.1.2 # via -r requirements/pip_tools.in
six==1.14.0 # via pip-tools
pip-tools==5.5.0 # via -r requirements/pip_tools.in

# The following packages are considered to be unsafe in a requirements file:
# pip
59 changes: 29 additions & 30 deletions requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,43 @@
#
# make upgrade
#
attrs==19.3.0 # via pytest
bleach==3.1.5 # via readme-renderer
bumpversion==0.5.3 # via -r requirements/test.in
certifi==2020.4.5.1 # via requests
chardet==3.0.4 # via requests
attrs==20.3.0 # via pytest
bleach==3.2.1 # via readme-renderer
bump2version==1.0.1 # via bumpversion
bumpversion==0.6.0 # via -r requirements/test.in
certifi==2020.12.5 # via requests
chardet==4.0.0 # via requests
click==7.1.2 # via -r requirements/base.txt
coverage==5.1 # via -r requirements/test.in
colorama==0.4.4 # via twine
coverage==5.3.1 # via -r requirements/test.in
docutils==0.16 # via readme-renderer
entrypoints==0.3 # via flake8
flake8==3.7.9 # via -r requirements/test.in
idna==2.9 # via requests
importlib-metadata==1.6.0 # via pluggy, pytest
flake8==3.8.4 # via -r requirements/test.in
idna==2.10 # via requests
iniconfig==1.1.1 # via pytest
keyring==21.8.0 # via twine
mccabe==0.6.1 # via flake8
more-itertools==8.2.0 # via pytest
packaging==20.3 # via bleach, pytest
pathlib2==2.3.5 # via pytest
pathtools==0.1.2 # via watchdog
pkginfo==1.5.0.1 # via twine
packaging==20.8 # via bleach, pytest
pkginfo==1.7.0 # via twine
pluggy==0.13.1 # via pytest
py==1.8.1 # via pytest
pycodestyle==2.5.0 # via flake8
pyflakes==2.1.1 # via flake8
pygments==2.6.1 # via readme-renderer
py==1.10.0 # via pytest
pycodestyle==2.6.0 # via flake8
pyflakes==2.2.0 # via flake8
pygments==2.7.4 # via readme-renderer
pyparsing==2.4.7 # via packaging
pytest-runner==5.2 # via -r requirements/test.in
pytest==5.4.1 # via -r requirements/test.in
readme-renderer==26.0 # via twine
pytest==6.2.1 # via -r requirements/test.in
readme-renderer==28.0 # via twine
requests-toolbelt==0.9.1 # via twine
requests==2.23.0 # via requests-toolbelt, twine
six==1.14.0 # via bleach, packaging, pathlib2, readme-renderer
tqdm==4.46.0 # via twine
twine==1.15.0 # via -r requirements/test.in
urllib3==1.25.9 # via requests
watchdog==0.10.2 # via -r requirements/test.in
wcwidth==0.1.9 # via pytest
requests==2.25.1 # via requests-toolbelt, twine
rfc3986==1.4.0 # via twine
six==1.15.0 # via bleach, readme-renderer
toml==0.10.2 # via pytest
tqdm==4.56.0 # via twine
twine==3.3.0 # via -r requirements/test.in
urllib3==1.26.2 # via requests
watchdog==1.0.2 # via -r requirements/test.in
webencodings==0.5.1 # via bleach
wheel==0.34.2 # via -r requirements/test.in
zipp==1.2.0 # via importlib-metadata
wheel==0.36.2 # via -r requirements/test.in

# The following packages are considered to be unsafe in a requirements file:
# setuptools
19 changes: 8 additions & 11 deletions requirements/tox.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,14 @@
#
# make upgrade
#
appdirs==1.4.3 # via virtualenv
distlib==0.3.0 # via virtualenv
appdirs==1.4.4 # via virtualenv
distlib==0.3.1 # via virtualenv
filelock==3.0.12 # via tox, virtualenv
importlib-metadata==1.6.0 # via importlib-resources, pluggy, tox, virtualenv
importlib-resources==1.5.0 # via virtualenv
packaging==20.3 # via tox
packaging==20.8 # via tox
pluggy==0.13.1 # via tox
py==1.8.1 # via tox
py==1.10.0 # via tox
pyparsing==2.4.7 # via packaging
six==1.14.0 # via packaging, tox, virtualenv
toml==0.10.0 # via tox
tox==3.15.0 # via -r requirements/tox.in
virtualenv==20.0.20 # via tox
zipp==1.2.0 # via importlib-metadata, importlib-resources
six==1.15.0 # via tox, virtualenv
toml==0.10.2 # via tox
tox==3.21.2 # via -r requirements/tox.in
virtualenv==20.4.0 # via tox
19 changes: 8 additions & 11 deletions requirements/travis.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,15 @@
#
# make upgrade
#
appdirs==1.4.3 # via -r requirements/tox.txt, virtualenv
distlib==0.3.0 # via -r requirements/tox.txt, virtualenv
appdirs==1.4.4 # via -r requirements/tox.txt, virtualenv
distlib==0.3.1 # via -r requirements/tox.txt, virtualenv
filelock==3.0.12 # via -r requirements/tox.txt, tox, virtualenv
importlib-metadata==1.6.0 # via -r requirements/tox.txt, importlib-resources, pluggy, tox, virtualenv
importlib-resources==1.5.0 # via -r requirements/tox.txt, virtualenv
packaging==20.3 # via -r requirements/tox.txt, tox
packaging==20.8 # via -r requirements/tox.txt, tox
pluggy==0.13.1 # via -r requirements/tox.txt, tox
py==1.8.1 # via -r requirements/tox.txt, tox
py==1.10.0 # via -r requirements/tox.txt, tox
pyparsing==2.4.7 # via -r requirements/tox.txt, packaging
six==1.14.0 # via -r requirements/tox.txt, packaging, tox, virtualenv
toml==0.10.0 # via -r requirements/tox.txt, tox
six==1.15.0 # via -r requirements/tox.txt, tox, virtualenv
toml==0.10.2 # via -r requirements/tox.txt, tox
tox-travis==0.12 # via -r requirements/travis.in
tox==3.15.0 # via -r requirements/tox.txt, tox-travis
virtualenv==20.0.20 # via -r requirements/tox.txt, tox
zipp==1.2.0 # via -r requirements/tox.txt, importlib-metadata, importlib-resources
tox==3.21.2 # via -r requirements/tox.txt, tox-travis
virtualenv==20.4.0 # via -r requirements/tox.txt, tox
4 changes: 1 addition & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""The setup script."""

Expand Down Expand Up @@ -48,7 +47,6 @@ def is_requirement(line):
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'Natural Language :: English',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.8',
],
description="User utilities for the Open edX platform",
Expand All @@ -68,6 +66,6 @@ def is_requirement(line):
test_suite='tests',
tests_require=test_requirements,
url='https://github.com/edx/user-util',
version='0.3.1',
version='1.0.0',
zip_safe=False,
)
7 changes: 3 additions & 4 deletions tests/test_user_util.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""Tests for `user_util` package."""

Expand Down Expand Up @@ -100,7 +99,7 @@ def test_username_to_hash_is_normalized(salt_list):


def test_unicode_username_to_hash():
username = u'ÁĹéáŕńéŕŰśéŕŃáḿéẂíthŰńíćődé'
username = 'ÁĹéáŕńéŕŰśéŕŃáḿéẂíthŰńíćődé'
retired_username = user_util.get_retired_username(username, VALID_SALT_LIST_ONE_SALT)
assert retired_username != username
# Since SHA1 is used, the hexadecimal digest length should be 40.
Expand Down Expand Up @@ -168,7 +167,7 @@ def test_email_to_hash_is_normalized(salt_list):


def test_unicode_email_to_hash():
email = u'🅐.🅛🅔🅐🅡🅝🅔🅡[email protected]'
email = '🅐.🅛🅔🅐🅡🅝🅔🅡[email protected]'
retired_email = user_util.get_retired_email(email, VALID_SALT_LIST_ONE_SALT)
assert retired_email != email
# Since SHA1 is used, the hexadecimal digest length should be 40.
Expand Down Expand Up @@ -237,7 +236,7 @@ def test_external_key_to_hash(salt_list):


def test_unicode_external_key_to_hash():
unicode_external_key = u'🅐.🅛🅔🅐🅡🅝🅔🅡'
unicode_external_key = '🅐.🅛🅔🅐🅡🅝🅔🅡'
retired_external_key= user_util.get_retired_external_key(unicode_external_key, VALID_SALT_LIST_ONE_SALT)
assert retired_external_key != unicode_external_key
# Since SHA1 is used, the hexadecimal digest length should be 40.
Expand Down
26 changes: 13 additions & 13 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
[tox]
envlist = py{35}-django{22},py{38}-django{22,30},quality
envlist = py38-django{22,30,31},quality

[travis]
python =
3.5: py35
3.8: py38
quality: flake8
python =
3.8: py38
quality: flake8

[testenv:quality]
basepython = python
deps = flake8
commands = flake8 user_util

[testenv]
setenv =
PYTHONPATH = {toxinidir}
deps =
-r requirements/test.txt
commands =
pip install -U pip
python setup.py develop
py.test --basetemp={envtmpdir}
setenv =
PYTHONPATH = {toxinidir}
deps =
-r requirements/test.txt
commands =
pip install -U pip
python setup.py develop
py.test --basetemp={envtmpdir}

2 changes: 0 additions & 2 deletions user_util/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

"""Top-level package for Open edX User Utilities."""

__version__ = '0.3.1'
4 changes: 1 addition & 3 deletions user_util/cli.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

"""Console script for user_util."""
import json
import sys
Expand Down Expand Up @@ -28,7 +26,7 @@ def retire_user(username, email, salt):
try:
salt_list = json.loads(salt)
except (TypeError, ValueError):
click.echo("Salt value \"{}\" is invalid JSON.".format(salt))
click.echo(f"Salt value \"{salt}\" is invalid JSON.")
raise
results = {}
for name in username:
Expand Down
2 changes: 0 additions & 2 deletions user_util/user_util.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

"""Main module."""
import hashlib

Expand Down

0 comments on commit 051587b

Please sign in to comment.