Skip to content

Commit d021902

Browse files
committed
Remove comments and fix PEP8 issues
1 parent c8c63d8 commit d021902

3 files changed

Lines changed: 12 additions & 21 deletions

File tree

saml/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@
99
"""
1010
# Version of the library.
1111
from ._version import __version__, __version_info__ # noqa
12-
VERSION = __version__
1312

1413
# Version of the SAML standard supported.
1514
from .schema import VERSION as SAML_VERSION
1615

1716
from .signature import sign, verify
1817
from . import client
1918

19+
VERSION = __version__
20+
2021
__all__ = [
2122
'VERSION',
2223
'SAML_VERSION',

saml/schema/base.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ def _is_derived(cls, name, bases):
5555
# This is not derived at all from Resource (eg. is base).
5656
return False
5757

58+
@classmethod
59+
def _get_attributes_dict(cls, obj):
60+
return {n: getattr(obj, n) for n in dir(obj)}
61+
5862
def __new__(cls, name, bases, attrs):
5963
# Only continue if we are dervied from declarative.
6064
if not cls._is_derived(name, bases):
@@ -64,20 +68,19 @@ def __new__(cls, name, bases, attrs):
6468
# Gather the attributes of all options classes.
6569
# Start with the base configuration.
6670
metadata = {}
67-
values = lambda x: {n: getattr(x, n) for n in dir(x)}
6871

6972
# Expand the options class with the gathered metadata.
7073
base_meta = []
7174
cls._gather_metadata(base_meta, bases)
7275

7376
# Apply the configuration from each class in the chain.
7477
for meta in base_meta:
75-
metadata.update(**values(meta))
78+
metadata.update(**cls._get_attributes_dict(meta))
7679

7780
# Apply the configuration from the current class.
7881
cur_meta = {}
7982
if attrs.get('Meta'):
80-
cur_meta = values(attrs['Meta'])
83+
cur_meta = cls._get_attributes_dict(attrs['Meta'])
8184
metadata.update(**cur_meta)
8285

8386
# Gather and construct the options object.
@@ -93,8 +96,8 @@ def __new__(cls, name, bases, attrs):
9396
attrs['_items'].update(values)
9497

9598
# Collect attributes from current class.
96-
test = lambda x: issubclass(type(x[1]), Component)
97-
attrs_l = list(filter(test, attrs.items()))
99+
attrs_l = list(filter(lambda x: issubclass(type(x[1]), Component),
100+
attrs.items()))
98101
attrs_l.sort(key=lambda x: x[1].creation_counter)
99102
for key, attr in attrs_l:
100103
# If name reference is null; default to camel-cased name.

tests/test_schema.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -303,15 +303,6 @@ def test_generic_deserialize_outside_registry():
303303
assert result is None
304304

305305

306-
# NAMES = [
307-
# 'assertion',
308-
# 'response',
309-
# 'logout-response',
310-
# 'artifact-resolve',
311-
# 'artifact-response'
312-
# ]
313-
314-
315306
@mark.parametrize('name', NAMES)
316307
def test_sign(name):
317308
# Load the expected result.
@@ -330,10 +321,6 @@ def test_sign(name):
330321
# Sign the result.
331322
saml.sign(result, stream)
332323

333-
# print()
334-
# print(etree.tostring(result).decode('utf8'))
335-
# print()
336-
337324
# Compare the nodes.
338325
assert_node(expected, result)
339326

@@ -358,7 +345,7 @@ def test_verify_with_bad_signature_returns_False(name):
358345
signature_node.clear()
359346

360347
with open(path.join(BASE_DIR, 'rsapub.pem'), 'r') as stream:
361-
assert saml.verify(expected, stream) == False
348+
assert saml.verify(expected, stream) is False
362349

363350

364351
@mark.parametrize('name', NAMES)
@@ -367,4 +354,4 @@ def test_verify_with_no_signature_returns_False(name):
367354
expected = etree.parse(filename).getroot()
368355

369356
with open(path.join(BASE_DIR, 'rsapub.pem'), 'r') as stream:
370-
assert saml.verify(expected, stream) == False
357+
assert saml.verify(expected, stream) is False

0 commit comments

Comments
 (0)