Skip to content

Commit 269f68e

Browse files
Merge pull request #424 from bajnokk/flake8
Flake8 non-formatting changes
2 parents 28b3c36 + 502e875 commit 269f68e

27 files changed

+58
-73
lines changed

src/satosa/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# -*- coding: utf-8 -*-
22
"""SATOSA: An any to any Single Sign On (SSO) proxy."""
33

4-
from .version import version as __version__
4+
from .version import version as __version__ # noqa: F401

src/satosa/backends/apple.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
from ..exception import SATOSAAuthenticationError, SATOSAError
2323
from ..response import Redirect
2424

25-
import base64
2625
import json
2726
import requests
2827

@@ -211,7 +210,7 @@ def response_endpoint(self, context, *args):
211210
try:
212211
userdata = context.request.get("user", "{}")
213212
userinfo = json.load(userdata)
214-
except Exception as e:
213+
except Exception:
215214
userinfo = {}
216215

217216
authn_resp = self.client.parse_response(

src/satosa/backends/oauth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ def user_information(self, access_token):
259259
try:
260260
picture_url = data["picture"]["data"]["url"]
261261
data["picture"] = picture_url
262-
except KeyError as e:
262+
except KeyError:
263263
pass
264264
return data
265265

src/satosa/backends/reflector.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
A reflector backend module for the satosa proxy
33
"""
4+
import base64
45
from datetime import datetime
56

67
from satosa.internal import AuthenticationInformation
@@ -74,7 +75,7 @@ def get_metadata_desc(self):
7475
"""
7576
entity_descriptions = []
7677
description = MetadataDescription(
77-
urlsafe_b64encode(ReflectorBackend.ENTITY_ID.encode("utf-8")).decode(
78+
base64.urlsafe_b64encode(ReflectorBackend.ENTITY_ID.encode("utf-8")).decode(
7879
"utf-8"
7980
)
8081
)

src/satosa/base.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
from satosa import util
1111
from .context import Context
12-
from .exception import SATOSAConfigurationError
1312
from .exception import SATOSAError, SATOSAAuthenticationError, SATOSAUnknownError
1413
from .plugin_loader import load_backends, load_frontends
1514
from .plugin_loader import load_request_microservices, load_response_microservices
@@ -201,7 +200,7 @@ def _load_state(self, context):
201200
self.config["COOKIE_STATE_NAME"],
202201
self.config["STATE_ENCRYPTION_KEY"],
203202
)
204-
except SATOSAStateError as e:
203+
except SATOSAStateError:
205204
state = State()
206205
finally:
207206
context.state = state

src/satosa/frontends/ping.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import satosa.logging_util as lu
44
import satosa.micro_services.base
5-
from satosa.logging_util import satosa_logging
65
from satosa.response import Response
76

87

src/satosa/frontends/saml2.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,8 @@ def _validate_config(self, config):
173173
raise ValueError("No configuration given")
174174

175175
for key in required_keys:
176-
try:
177-
_val = config[key]
178-
except KeyError as e:
179-
raise ValueError("Missing configuration key: %s" % key) from e
176+
if key not in config:
177+
raise ValueError("Missing configuration key: %s" % key)
180178

181179
def _handle_authn_request(self, context, binding_in, idp):
182180
"""
@@ -630,7 +628,7 @@ def _get_sp_display_name(self, idp, entity_id):
630628

631629
try:
632630
return extensions[0]["display_name"]
633-
except (IndexError, KeyError) as e:
631+
except (IndexError, KeyError):
634632
pass
635633

636634
return None

src/satosa/micro_services/attribute_processor.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import importlib
2-
import json
32
import logging
43

54
from satosa.exception import SATOSAError

src/satosa/micro_services/consent.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def _handle_consent_response(self, context):
6666
except ConnectionError as e:
6767
msg = "Consent service is not reachable, no consent given."
6868
logline = lu.LOG_FMT.format(id=lu.get_session_id(context.state), message=msg)
69-
logger.error(logline)
69+
logger.error(logline, exc_info=e)
7070
# Send an internal_response without any attributes
7171
consent_attributes = None
7272

@@ -136,7 +136,7 @@ def process(self, context, internal_response):
136136
except requests.exceptions.ConnectionError as e:
137137
msg = "Consent service is not reachable, no consent is given."
138138
logline = lu.LOG_FMT.format(id=lu.get_session_id(context.state), message=msg)
139-
logger.error(logline)
139+
logger.error(logline, exc_info=e)
140140
# Send an internal_response without any attributes
141141
internal_response.attributes = {}
142142
return self._end_consent(context, internal_response)

src/satosa/micro_services/custom_logging.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def process(self, context, data):
3939
try:
4040
spEntityID = context.state.state_dict['SATOSA_BASE']['requester']
4141
idpEntityID = data.auth_info.issuer
42-
except KeyError as err:
42+
except KeyError:
4343
msg = "{} Unable to determine the entityID's for the IdP or SP".format(logprefix)
4444
logline = lu.LOG_FMT.format(id=lu.get_session_id(context.state), message=msg)
4545
logger.error(logline)
@@ -71,8 +71,6 @@ def process(self, context, data):
7171
logger.error(logline)
7272
return super().process(context, data)
7373

74-
record = None
75-
7674
try:
7775
msg = "{} Using context {}".format(logprefix, context)
7876
logline = lu.LOG_FMT.format(id=lu.get_session_id(context.state), message=msg)

0 commit comments

Comments
 (0)