Skip to content

Commit cf92374

Browse files
committed
chore: address all pylint issues aside from TODO references
1 parent f6b2a4e commit cf92374

File tree

16 files changed

+97
-54
lines changed

16 files changed

+97
-54
lines changed

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def get_version():
2323
def get_requirements():
2424
"""Reads the requirements file."""
2525
requirements = read("requirements.txt")
26-
return [r for r in requirements.strip().splitlines()]
26+
return requirements.strip().splitlines()
2727

2828

2929
setup(

src/dynamodb_encryption_sdk/encrypted/item.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def decrypt_dynamodb_item(item, crypto_config):
171171
:rtype: dict
172172
"""
173173
unique_actions = set([crypto_config.attribute_actions.default_action.name])
174-
unique_actions.update(set([action.name for action in crypto_config.attribute_actions.attribute_actions.values()]))
174+
unique_actions.update({action.name for action in crypto_config.attribute_actions.attribute_actions.values()})
175175

176176
if crypto_config.attribute_actions.take_no_actions:
177177
# If we explicitly have been told not to do anything to this item, just copy it.

src/dynamodb_encryption_sdk/encrypted/resource.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
@attr.s(init=False)
4343
class EncryptedTablesCollectionManager(object):
44-
# pylint: disable=too-few-public-methods
44+
# pylint: disable=too-few-public-methods,too-many-instance-attributes
4545
"""Tables collection manager that provides :class:`EncryptedTable` objects.
4646
4747
https://boto3.readthedocs.io/en/latest/reference/services/dynamodb.html#DynamoDB.ServiceResource.tables
@@ -119,7 +119,7 @@ def _transform_table(self, method, **kwargs):
119119

120120
@attr.s(init=False)
121121
class EncryptedResource(object):
122-
# pylint: disable=too-few-public-methods
122+
# pylint: disable=too-few-public-methods,too-many-instance-attributes
123123
"""High-level helper class to provide a familiar interface to encrypted tables.
124124
125125
>>> import boto3

src/dynamodb_encryption_sdk/encrypted/table.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
@attr.s(init=False)
4444
class EncryptedTable(object):
45-
# pylint: disable=too-few-public-methods
45+
# pylint: disable=too-few-public-methods,too-many-instance-attributes
4646
"""High-level helper class to provide a familiar interface to encrypted tables.
4747
4848
>>> import boto3

src/dynamodb_encryption_sdk/identifiers.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ def __gt__(self, other):
3535
def __lt__(self, other):
3636
# type: (CryptoAction) -> bool
3737
"""Define CryptoAction equality."""
38-
return self.value < other.value
38+
return self.value < other.value # pylint: disable=comparison-with-callable
3939

4040
def __eq__(self, other):
4141
# type: (CryptoAction) -> bool
4242
"""Define CryptoAction equality."""
43-
return self.value == other.value
43+
return self.value == other.value # pylint: disable=comparison-with-callable
4444

4545

4646
class EncryptionKeyType(Enum):

src/dynamodb_encryption_sdk/internal/crypto/authentication.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ def sign_item(encrypted_item, signing_key, crypto_config):
5656
attribute_actions=crypto_config.attribute_actions,
5757
),
5858
)
59-
return {Tag.BINARY.dynamodb_tag: signature}
59+
# for some reason pylint can't follow the Enum member attributes
60+
return {Tag.BINARY.dynamodb_tag: signature} # pylint: disable=no-member
6061

6162

6263
def verify_item_signature(signature_attribute, encrypted_item, verification_key, crypto_config):
@@ -68,7 +69,8 @@ def verify_item_signature(signature_attribute, encrypted_item, verification_key,
6869
:param DelegatedKey verification_key: DelegatedKey to use to calculate the signature
6970
:param CryptoConfig crypto_config: Cryptographic configuration
7071
"""
71-
signature = signature_attribute[Tag.BINARY.dynamodb_tag]
72+
# for some reason pylint can't follow the Enum member attributes
73+
signature = signature_attribute[Tag.BINARY.dynamodb_tag] # pylint: disable=no-member
7274
verification_key.verify(
7375
algorithm=verification_key.algorithm,
7476
signature=signature,
@@ -98,10 +100,11 @@ def _string_to_sign(item, table_name, attribute_actions):
98100

99101
data_to_sign.extend(_hash_data(hasher=hasher, data=key.encode(TEXT_ENCODING)))
100102

103+
# for some reason pylint can't follow the Enum member attributes
101104
if action is CryptoAction.SIGN_ONLY:
102-
data_to_sign.extend(SignatureValues.PLAINTEXT.sha256)
105+
data_to_sign.extend(SignatureValues.PLAINTEXT.sha256) # pylint: disable=no-member
103106
else:
104-
data_to_sign.extend(SignatureValues.ENCRYPTED.sha256)
107+
data_to_sign.extend(SignatureValues.ENCRYPTED.sha256) # pylint: disable=no-member
105108

106109
data_to_sign.extend(_hash_data(hasher=hasher, data=serialize_attribute(item[key])))
107110
return bytes(data_to_sign)

src/dynamodb_encryption_sdk/internal/crypto/encryption.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ def encrypt_attribute(attribute_name, attribute, encryption_key, algorithm):
4747
encrypted_attribute = encryption_key.encrypt(
4848
algorithm=algorithm, name=attribute_name, plaintext=serialized_attribute
4949
)
50-
return {Tag.BINARY.dynamodb_tag: encrypted_attribute}
50+
# for some reason pylint can't follow the Enum member attributes
51+
return {Tag.BINARY.dynamodb_tag: encrypted_attribute} # pylint: disable=no-member
5152

5253

5354
def decrypt_attribute(attribute_name, attribute, decryption_key, algorithm):
@@ -61,7 +62,8 @@ def decrypt_attribute(attribute_name, attribute, decryption_key, algorithm):
6162
:returns: Plaintext DynamoDB attribute
6263
:rtype: dict
6364
"""
64-
encrypted_attribute = attribute[Tag.BINARY.dynamodb_tag]
65+
# for some reason pylint can't follow the Enum member attributes
66+
encrypted_attribute = attribute[Tag.BINARY.dynamodb_tag] # pylint: disable=no-member
6567
decrypted_attribute = decryption_key.decrypt(
6668
algorithm=algorithm, name=attribute_name, ciphertext=encrypted_attribute
6769
)

src/dynamodb_encryption_sdk/internal/crypto/jce_bridge/authentication.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def load_key(self, key, key_type, key_encoding):
139139
raise ValueError("Key type must be symmetric and encoding must be raw.")
140140

141141
if len(key) * 8 < MinimumKeySizes.HMAC.value:
142-
_LOGGER.warning("HMAC keys smaller than %d bits are unsafe" % MinimumKeySizes.HMAC.value)
142+
_LOGGER.warning("HMAC keys smaller than %d bits are unsafe", MinimumKeySizes.HMAC.value)
143143

144144
return key
145145

src/dynamodb_encryption_sdk/internal/crypto/jce_bridge/primitives.py

+5-9
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,7 @@ class SimplePadding(JavaPadding):
121121
java_name = attr.ib(validator=attr.validators.instance_of(six.string_types))
122122
padding = attr.ib(validator=callable_validator)
123123

124-
def __init__(self, java_name, padding): # type: Text # type: Callable # noqa=D107
125-
# type: (...) -> None
124+
def __init__(self, java_name, padding): # type: (Text, Callable) -> None # noqa=D107
126125
# Workaround pending resolution of attrs/mypy interaction.
127126
# https://github.com/python/mypy/issues/2088
128127
# https://github.com/python-attrs/attrs/issues/215
@@ -148,8 +147,7 @@ class BlockSizePadding(JavaPadding):
148147
java_name = attr.ib(validator=attr.validators.instance_of(six.string_types))
149148
padding = attr.ib(validator=callable_validator)
150149

151-
def __init__(self, java_name, padding): # type: Text # type: Callable # noqa=D107
152-
# type: (...) -> None
150+
def __init__(self, java_name, padding): # type: (Text, Callable) -> None # noqa=D107
153151
# Workaround pending resolution of attrs/mypy interaction.
154152
# https://github.com/python/mypy/issues/2088
155153
# https://github.com/python-attrs/attrs/issues/215
@@ -227,8 +225,7 @@ class JavaMode(object):
227225
java_name = attr.ib(validator=attr.validators.instance_of(six.string_types))
228226
mode = attr.ib(validator=callable_validator)
229227

230-
def __init__(self, java_name, mode): # type: Text # type: Callable # noqa=D107
231-
# type: (...) -> None
228+
def __init__(self, java_name, mode): # type: (Text, Callable) -> None # noqa=D107
232229
# Workaround pending resolution of attrs/mypy interaction.
233230
# https://github.com/python/mypy/issues/2088
234231
# https://github.com/python-attrs/attrs/issues/215
@@ -256,8 +253,7 @@ class JavaEncryptionAlgorithm(object):
256253
java_name = attr.ib(validator=attr.validators.instance_of(six.string_types))
257254
cipher = attr.ib()
258255

259-
def __init__(self, java_name, cipher): # type: Text # type: Callable # noqa=D107
260-
# type: (...) -> None
256+
def __init__(self, java_name, cipher): # type: (Text, Callable) -> None # noqa=D107
261257
# Workaround pending resolution of attrs/mypy interaction.
262258
# https://github.com/python/mypy/issues/2088
263259
# https://github.com/python-attrs/attrs/issues/215
@@ -455,7 +451,7 @@ def load_rsa_key(key, key_type, key_encoding):
455451
loaded_key = loader(**kwargs)
456452

457453
if loaded_key.key_size < MinimumKeySizes.RSA.value:
458-
_LOGGER.warning("RSA keys smaller than %d bits are unsafe" % MinimumKeySizes.RSA.value)
454+
_LOGGER.warning("RSA keys smaller than %d bits are unsafe", MinimumKeySizes.RSA.value)
459455

460456
return loaded_key
461457

src/dynamodb_encryption_sdk/internal/dynamodb_types.py

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
No guarantee is provided on the modules and APIs within this
55
namespace staying consistent. Directly reference at your own risk.
66
"""
7+
# constant naming for types so pylint: disable=invalid-name
78
try: # Python 3.5.0 and 3.5.1 have incompatible typing modules
89
from typing import Any, AnyStr, ByteString, Dict, List, Text
910

src/dynamodb_encryption_sdk/internal/formatting/deserialize/attribute.py

+33-13
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ def _transform_binary_value(value):
6565

6666
def _deserialize_binary(stream):
6767
# type: (io.BytesIO) -> Dict[Text, bytes]
68+
# pylint: disable=no-member
69+
# for some reason pylint can't follow the Enum member attributes
6870
"""Deserializes a binary object.
6971
7072
:param stream: Stream containing serialized object
@@ -85,6 +87,8 @@ def _transform_string_value(value):
8587

8688
def _deserialize_string(stream):
8789
# type: (io.BytesIO) -> Dict[Text, dynamodb_types.STRING]
90+
# pylint: disable=no-member
91+
# for some reason pylint can't follow the Enum member attributes
8892
"""Deserializes a string object.
8993
9094
:param stream: Stream containing serialized object
@@ -107,6 +111,8 @@ def _transform_number_value(value):
107111

108112
def _deserialize_number(stream):
109113
# type: (io.BytesIO) -> Dict[Text, dynamodb_types.STRING]
114+
# pylint: disable=no-member
115+
# for some reason pylint can't follow the Enum member attributes
110116
"""Deserializes a number object.
111117
112118
:param stream: Stream containing serialized object
@@ -120,6 +126,8 @@ def _deserialize_number(stream):
120126

121127
def _deserialize_boolean(stream):
122128
# type: (io.BytesIO) -> Dict[Text, dynamodb_types.BOOLEAN]
129+
# pylint: disable=no-member
130+
# for some reason pylint can't follow the Enum member attributes
123131
"""Deserializes a boolean object.
124132
125133
:param stream: Stream containing serialized object
@@ -131,6 +139,8 @@ def _deserialize_boolean(stream):
131139

132140
def _deserialize_null(stream): # we want a consistent API but don't use stream, so pylint: disable=unused-argument
133141
# type: (io.BytesIO) -> Dict[Text, dynamodb_types.BOOLEAN]
142+
# pylint: disable=no-member
143+
# for some reason pylint can't follow the Enum member attributes
134144
"""Deserializes a null object.
135145
136146
:param stream: Stream containing serialized object
@@ -152,6 +162,8 @@ def _deserialize_set(stream, member_transform):
152162

153163
def _deserialize_binary_set(stream):
154164
# type: (io.BytesIO) -> Dict[Text, dynamodb_types.SET[dynamodb_types.BINARY]]
165+
# pylint: disable=no-member
166+
# for some reason pylint can't follow the Enum member attributes
155167
"""Deserializes a binary set object.
156168
157169
:param stream: Stream containing serialized object
@@ -162,6 +174,8 @@ def _deserialize_binary_set(stream):
162174

163175
def _deserialize_string_set(stream):
164176
# type: (io.BytesIO) -> Dict[Text, dynamodb_types.SET[dynamodb_types.STRING]]
177+
# pylint: disable=no-member
178+
# for some reason pylint can't follow the Enum member attributes
165179
"""Deserializes a string set object.
166180
167181
:param stream: Stream containing serialized object
@@ -172,6 +186,8 @@ def _deserialize_string_set(stream):
172186

173187
def _deserialize_number_set(stream):
174188
# type: (io.BytesIO) -> Dict[Text, dynamodb_types.SET[dynamodb_types.STRING]]
189+
# pylint: disable=no-member
190+
# for some reason pylint can't follow the Enum member attributes
175191
"""Deserializes a number set object.
176192
177193
:param stream: Stream containing serialized object
@@ -182,6 +198,8 @@ def _deserialize_number_set(stream):
182198

183199
def _deserialize_list(stream):
184200
# type: (io.BytesIO) -> Dict[Text, dynamodb_types.LIST]
201+
# pylint: disable=no-member
202+
# for some reason pylint can't follow the Enum member attributes
185203
"""Deserializes a list object.
186204
187205
:param stream: Stream containing serialized object
@@ -199,19 +217,20 @@ def _deserialize_map(stream):
199217
:type stream: io.BytesIO
200218
:rtype: dict
201219
"""
220+
# for some reason pylint can't follow the Enum member attributes
202221
member_count = decode_length(stream)
203222
members = {} # type: dynamodb_types.MAP
204223
for _ in range(member_count):
205224
key = _deserialize(stream)
206-
if Tag.STRING.dynamodb_tag not in key:
225+
if Tag.STRING.dynamodb_tag not in key: # pylint: disable=no-member
207226
raise DeserializationError(
208227
'Malformed serialized map: found "{}" as map key.'.format(list(key.keys())[0])
209228
)
210229

211230
value = _deserialize(stream)
212-
members[key[Tag.STRING.dynamodb_tag]] = value
231+
members[key[Tag.STRING.dynamodb_tag]] = value # pylint: disable=no-member
213232

214-
return {Tag.MAP.dynamodb_tag: members}
233+
return {Tag.MAP.dynamodb_tag: members} # pylint: disable=no-member
215234

216235
def _deserialize_function(tag):
217236
# type: (bytes) -> Callable
@@ -221,17 +240,18 @@ def _deserialize_function(tag):
221240
:type tag: dynamodb_encryption_sdk.internal.identifiers.Tag
222241
:rtype: callable
223242
"""
243+
# for some reason pylint can't follow the Enum member attributes
224244
deserialize_functions = {
225-
Tag.BINARY.tag: _deserialize_binary,
226-
Tag.BINARY_SET.tag: _deserialize_binary_set,
227-
Tag.NUMBER.tag: _deserialize_number,
228-
Tag.NUMBER_SET.tag: _deserialize_number_set,
229-
Tag.STRING.tag: _deserialize_string,
230-
Tag.STRING_SET.tag: _deserialize_string_set,
231-
Tag.BOOLEAN.tag: _deserialize_boolean,
232-
Tag.NULL.tag: _deserialize_null,
233-
Tag.LIST.tag: _deserialize_list,
234-
Tag.MAP.tag: _deserialize_map,
245+
Tag.BINARY.tag: _deserialize_binary, # pylint: disable=no-member
246+
Tag.BINARY_SET.tag: _deserialize_binary_set, # pylint: disable=no-member
247+
Tag.NUMBER.tag: _deserialize_number, # pylint: disable=no-member
248+
Tag.NUMBER_SET.tag: _deserialize_number_set, # pylint: disable=no-member
249+
Tag.STRING.tag: _deserialize_string, # pylint: disable=no-member
250+
Tag.STRING_SET.tag: _deserialize_string_set, # pylint: disable=no-member
251+
Tag.BOOLEAN.tag: _deserialize_boolean, # pylint: disable=no-member
252+
Tag.NULL.tag: _deserialize_null, # pylint: disable=no-member
253+
Tag.LIST.tag: _deserialize_list, # pylint: disable=no-member
254+
Tag.MAP.tag: _deserialize_map, # pylint: disable=no-member
235255
}
236256
try:
237257
return deserialize_functions[tag]

src/dynamodb_encryption_sdk/internal/formatting/material_description.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ def serialize(material_description):
6363
'Invalid name or value in material description: "{name}"="{value}"'.format(name=name, value=value)
6464
)
6565

66-
return {Tag.BINARY.dynamodb_tag: bytes(material_description_bytes)}
66+
# for some reason pylint can't follow the Enum member attributes
67+
return {Tag.BINARY.dynamodb_tag: bytes(material_description_bytes)} # pylint: disable=no-member
6768

6869

6970
def deserialize(serialized_material_description):
@@ -77,7 +78,10 @@ def deserialize(serialized_material_description):
7778
:raises InvalidMaterialDescriptionVersionError: if unknown version is found
7879
"""
7980
try:
80-
_raw_material_description = serialized_material_description[Tag.BINARY.dynamodb_tag]
81+
# for some reason pylint can't follow the Enum member attributes
82+
_raw_material_description = serialized_material_description[
83+
Tag.BINARY.dynamodb_tag # pylint: disable=no-member
84+
]
8185

8286
material_description_bytes = io.BytesIO(_raw_material_description)
8387
total_bytes = len(_raw_material_description)

0 commit comments

Comments
 (0)