Skip to content

Commit

Permalink
Requirements updates and linting
Browse files Browse the repository at this point in the history
  • Loading branch information
AngellusMortis committed Jul 20, 2019
1 parent b9389a4 commit 3119d2d
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 13 deletions.
26 changes: 18 additions & 8 deletions microsoft_auth/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import errno
import os
import re
import subprocess
import subprocess # nosec
import sys


Expand Down Expand Up @@ -68,15 +68,17 @@ def decorate(f):
return decorate


def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False, env=None):
def run_command(
commands, args, cwd=None, verbose=False, hide_stderr=False, env=None
):
"""Call the given command(s)."""
assert isinstance(commands, list)
assert isinstance(commands, list) # nosec
p = None
for c in commands:
try:
dispcmd = str([c] + args)
# remember shell=False, so use git.cmd on windows, not just git
p = subprocess.Popen(
p = subprocess.Popen( # nosec
[c] + args,
cwd=cwd,
env=env,
Expand Down Expand Up @@ -241,7 +243,9 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):
if sys.platform == "win32":
GITS = ["git.cmd", "git.exe"]

out, rc = run_command(GITS, ["rev-parse", "--git-dir"], cwd=root, hide_stderr=True)
out, rc = run_command(
GITS, ["rev-parse", "--git-dir"], cwd=root, hide_stderr=True
)
if rc != 0:
if verbose:
print("Directory %s not under git control" % root)
Expand Down Expand Up @@ -293,7 +297,9 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):
mo = re.search(r"^(.+)-(\d+)-g([0-9a-f]+)$", git_describe)
if not mo:
# unparseable. Maybe git-describe is misbehaving?
pieces["error"] = "unable to parse git-describe output: '%s'" % describe_out
pieces["error"] = (
"unable to parse git-describe output: '%s'" % describe_out
)
return pieces

# tag
Expand All @@ -318,7 +324,9 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):
else:
# HEX: no tags
pieces["closest-tag"] = None
count_out, rc = run_command(GITS, ["rev-list", "HEAD", "--count"], cwd=root)
count_out, rc = run_command(
GITS, ["rev-list", "HEAD", "--count"], cwd=root
)
pieces["distance"] = int(count_out) # total number of commits

# commit date: see ISO-8601 comment in git_versions_from_keywords()
Expand Down Expand Up @@ -515,7 +523,9 @@ def get_versions():
verbose = cfg.verbose

try:
return git_versions_from_keywords(get_keywords(), cfg.tag_prefix, verbose)
return git_versions_from_keywords(
get_keywords(), cfg.tag_prefix, verbose
)
except NotThisMethod:
pass

Expand Down
4 changes: 3 additions & 1 deletion microsoft_auth/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ class MicrosoftClient(OAuth2Session):
_config_url = "https://login.microsoftonline.com/{tenant}/v2.0/.well-known/openid-configuration" # noqa

_xbox_authorization_url = "https://login.live.com/oauth20_authorize.srf"
_xbox_token_url = "https://user.auth.xboxlive.com/user/authenticate"
_xbox_token_url = (
"https://user.auth.xboxlive.com/user/authenticate" # nosec
)
_profile_url = "https://xsts.auth.xboxlive.com/xsts/authorize"

xbox_token = {}
Expand Down
2 changes: 1 addition & 1 deletion microsoft_auth/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ def microsoft(request):
auth_url = microsoft.authorization_url()[0]
return {
"microsoft_login_enabled": config.MICROSOFT_AUTH_LOGIN_ENABLED,
"microsoft_authorization_url": mark_safe(auth_url),
"microsoft_authorization_url": mark_safe(auth_url), # nosec
"microsoft_login_type_text": login_type,
}
2 changes: 1 addition & 1 deletion microsoft_auth/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def get_context_data(self, **kwargs):
if function is not None:
self.context = function(self.request, self.context)

self.context["message"] = mark_safe(
self.context["message"] = mark_safe( # nosec
json.dumps({"microsoft_auth": self.context["message"]})
)
return self.context
Expand Down
2 changes: 2 additions & 0 deletions tests/test_context_processors.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
""" isort:skip_file """

from unittest.mock import Mock, patch

import pytest
Expand Down
2 changes: 2 additions & 0 deletions tests/test_zconstance.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
Note: This file must be last in test runner as Constance does not get
cleaned correctly afterwards
isort:skip_file
"""

from unittest.mock import patch
Expand Down
4 changes: 2 additions & 2 deletions tox-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ cryptography==2.7
docopt==0.6.2 # via coveralls
entrypoints==0.3 # via flake8
filelock==3.0.12 # via tox
flake8==3.7.7
flake8==3.7.8
idna==2.8 # via requests
importlib-metadata==0.18 # via pluggy, pytest, tox
mccabe==0.6.1 # via flake8
Expand All @@ -40,6 +40,6 @@ toml==0.10.0 # via tox
tox==3.13.2
urllib3==1.25.3 # via requests
versioneer==0.18
virtualenv==16.6.1 # via tox
virtualenv==16.6.2 # via tox
wcwidth==0.1.7 # via pytest
zipp==0.5.2 # via importlib-metadata
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ commands=
flake8 microsoft_auth tests setup.py
isort --check-only --recursive
black --check microsoft_auth tests setup.py
bandit -r microsoft_auth

[testenv]
setenv =
Expand Down

0 comments on commit 3119d2d

Please sign in to comment.