Skip to content

Commit dd3efe9

Browse files
authored
cleaning up attrs/mypy workaround comments to remove them from rendered docs (#51)
1 parent 7e253d5 commit dd3efe9

File tree

18 files changed

+133
-162
lines changed

18 files changed

+133
-162
lines changed

src/dynamodb_encryption_sdk/delegated_keys/jce.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,12 @@ def __init__(
123123
key, # type: bytes
124124
algorithm, # type: Text
125125
key_type, # type: EncryptionKeyType
126-
key_encoding # type: KeyEncodingType
127-
):
126+
key_encoding, # type: KeyEncodingType
127+
): # noqa=D107
128128
# type: (...) -> None
129-
"""Workaround pending resolution of attrs/mypy interaction.
130-
https://github.com/python/mypy/issues/2088
131-
https://github.com/python-attrs/attrs/issues/215
132-
"""
129+
# Workaround pending resolution of attrs/mypy interaction.
130+
# https://github.com/python/mypy/issues/2088
131+
# https://github.com/python-attrs/attrs/issues/215
133132
self.key = key
134133
self._algorithm = algorithm
135134
self._key_type = key_type

src/dynamodb_encryption_sdk/encrypted/__init__.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,11 @@ def __init__(
5151
materials_provider, # type: CryptographicMaterialsProvider
5252
encryption_context, # type: EncryptionContext
5353
attribute_actions # type: AttributeActions
54-
):
54+
): # noqa=D107
5555
# type: (...) -> None
56-
"""Workaround pending resolution of attrs/mypy interaction.
57-
https://github.com/python/mypy/issues/2088
58-
https://github.com/python-attrs/attrs/issues/215
59-
"""
56+
# Workaround pending resolution of attrs/mypy interaction.
57+
# https://github.com/python/mypy/issues/2088
58+
# https://github.com/python-attrs/attrs/issues/215
6059
self.materials_provider = materials_provider
6160
self.encryption_context = encryption_context
6261
self.attribute_actions = attribute_actions

src/dynamodb_encryption_sdk/encrypted/client.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,11 @@ def __init__(
5555
paginator, # type: botocore.paginate.Paginator
5656
decrypt_method, # type: Callable
5757
crypto_config_method # type: Callable
58-
):
58+
): # noqa=D107
5959
# type: (...) -> None
60-
"""Workaround pending resolution of attrs/mypy interaction.
61-
https://github.com/python/mypy/issues/2088
62-
https://github.com/python-attrs/attrs/issues/215
63-
"""
60+
# Workaround pending resolution of attrs/mypy interaction.
61+
# https://github.com/python/mypy/issues/2088
62+
# https://github.com/python-attrs/attrs/issues/215
6463
self._paginator = paginator
6564
self._decrypt_method = decrypt_method
6665
self._crypto_config_method = crypto_config_method
@@ -172,12 +171,11 @@ def __init__(
172171
attribute_actions=None, # type: Optional[AttributeActions]
173172
auto_refresh_table_indexes=True, # type: Optional[bool]
174173
expect_standard_dictionaries=False # type: Optional[bool]
175-
):
174+
): # noqa=D107
176175
# type: (...) -> None
177-
"""Workaround pending resolution of attrs/mypy interaction.
178-
https://github.com/python/mypy/issues/2088
179-
https://github.com/python-attrs/attrs/issues/215
180-
"""
176+
# Workaround pending resolution of attrs/mypy interaction.
177+
# https://github.com/python/mypy/issues/2088
178+
# https://github.com/python-attrs/attrs/issues/215
181179
if attribute_actions is None:
182180
attribute_actions = AttributeActions()
183181

src/dynamodb_encryption_sdk/encrypted/resource.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,11 @@ def __init__(
5959
materials_provider, # type: CryptographicMaterialsProvider
6060
attribute_actions, # type: AttributeActions
6161
table_info_cache # type: TableInfoCache
62-
):
62+
): # noqa=D107
6363
# type: (...) -> None
64-
"""Workaround pending resolution of attrs/mypy interaction.
65-
https://github.com/python/mypy/issues/2088
66-
https://github.com/python-attrs/attrs/issues/215
67-
"""
64+
# Workaround pending resolution of attrs/mypy interaction.
65+
# https://github.com/python/mypy/issues/2088
66+
# https://github.com/python-attrs/attrs/issues/215
6867
self._collection = collection
6968
self._materials_provider = materials_provider
7069
self._attribute_actions = attribute_actions
@@ -168,12 +167,11 @@ def __init__(
168167
materials_provider, # type: CryptographicMaterialsProvider
169168
attribute_actions=None, # type: Optional[AttributeActions]
170169
auto_refresh_table_indexes=True # type: Optional[bool]
171-
):
170+
): # noqa=D107
172171
# type: (...) -> None
173-
"""Workaround pending resolution of attrs/mypy interaction.
174-
https://github.com/python/mypy/issues/2088
175-
https://github.com/python-attrs/attrs/issues/215
176-
"""
172+
# Workaround pending resolution of attrs/mypy interaction.
173+
# https://github.com/python/mypy/issues/2088
174+
# https://github.com/python-attrs/attrs/issues/215
177175
if attribute_actions is None:
178176
attribute_actions = AttributeActions()
179177

src/dynamodb_encryption_sdk/encrypted/table.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,11 @@ def __init__(
9898
table_info=None, # type: Optional[TableInfo]
9999
attribute_actions=None, # type: Optional[AttributeActions]
100100
auto_refresh_table_indexes=True # type: Optional[bool]
101-
):
101+
): # noqa=D107
102102
# type: (...) -> None
103-
"""Workaround pending resolution of attrs/mypy interaction.
104-
https://github.com/python/mypy/issues/2088
105-
https://github.com/python-attrs/attrs/issues/215
106-
"""
103+
# Workaround pending resolution of attrs/mypy interaction.
104+
# https://github.com/python/mypy/issues/2088
105+
# https://github.com/python-attrs/attrs/issues/215
107106
if attribute_actions is None:
108107
attribute_actions = AttributeActions()
109108

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,11 @@ def __init__(
102102
java_name, # type: Text
103103
algorithm_type, # type: Callable
104104
hash_type # type: Callable
105-
):
105+
): # noqa=D107
106106
# type: (...) -> None
107-
"""Workaround pending resolution of attrs/mypy interaction.
108-
https://github.com/python/mypy/issues/2088
109-
https://github.com/python-attrs/attrs/issues/215
110-
"""
107+
# Workaround pending resolution of attrs/mypy interaction.
108+
# https://github.com/python/mypy/issues/2088
109+
# https://github.com/python-attrs/attrs/issues/215
111110
self.java_name = java_name
112111
self.algorithm_type = algorithm_type
113112
self.hash_type = hash_type
@@ -213,12 +212,11 @@ def __init__(
213212
algorithm_type,
214213
hash_type, # type: Callable
215214
padding_type # type: Callable
216-
):
215+
): # noqa=D107
217216
# type: (...) -> None
218-
"""Workaround pending resolution of attrs/mypy interaction.
219-
https://github.com/python/mypy/issues/2088
220-
https://github.com/python-attrs/attrs/issues/215
221-
"""
217+
# Workaround pending resolution of attrs/mypy interaction.
218+
# https://github.com/python/mypy/issues/2088
219+
# https://github.com/python-attrs/attrs/issues/215
222220
self.java_name = java_name
223221
self.algorithm_type = algorithm_type
224222
self.hash_type = hash_type

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,11 @@ def __init__(
4141
cipher, # type: JavaEncryptionAlgorithm
4242
mode, # type: JavaMode
4343
padding # type: JavaPadding
44-
):
44+
): # noqa=D107
4545
# type: (...) -> None
46-
"""Workaround pending resolution of attrs/mypy interaction.
47-
https://github.com/python/mypy/issues/2088
48-
https://github.com/python-attrs/attrs/issues/215
49-
"""
46+
# Workaround pending resolution of attrs/mypy interaction.
47+
# https://github.com/python/mypy/issues/2088
48+
# https://github.com/python-attrs/attrs/issues/215
5049
self.cipher = cipher
5150
self.mode = mode
5251
self.padding = padding

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

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,11 @@ def __init__(
107107
self,
108108
java_name, # type: Text
109109
padding # type: Callable
110-
):
110+
): # noqa=D107
111111
# type: (...) -> None
112-
"""Workaround pending resolution of attrs/mypy interaction.
113-
https://github.com/python/mypy/issues/2088
114-
https://github.com/python-attrs/attrs/issues/215
115-
"""
112+
# Workaround pending resolution of attrs/mypy interaction.
113+
# https://github.com/python/mypy/issues/2088
114+
# https://github.com/python-attrs/attrs/issues/215
116115
self.java_name = java_name
117116
self.padding = padding
118117
attr.validate(self)
@@ -139,12 +138,11 @@ def __init__(
139138
self,
140139
java_name, # type: Text
141140
padding # type: Callable
142-
):
141+
): # noqa=D107
143142
# type: (...) -> None
144-
"""Workaround pending resolution of attrs/mypy interaction.
145-
https://github.com/python/mypy/issues/2088
146-
https://github.com/python-attrs/attrs/issues/215
147-
"""
143+
# Workaround pending resolution of attrs/mypy interaction.
144+
# https://github.com/python/mypy/issues/2088
145+
# https://github.com/python-attrs/attrs/issues/215
148146
self.java_name = java_name
149147
self.padding = padding
150148
attr.validate(self)
@@ -187,12 +185,11 @@ def __init__(
187185
digest, # type: Callable
188186
mgf, # type: Callable
189187
mgf_digest # type: Callable
190-
):
188+
): # noqa=D107
191189
# type: (...) -> None
192-
"""Workaround pending resolution of attrs/mypy interaction.
193-
https://github.com/python/mypy/issues/2088
194-
https://github.com/python-attrs/attrs/issues/215
195-
"""
190+
# Workaround pending resolution of attrs/mypy interaction.
191+
# https://github.com/python/mypy/issues/2088
192+
# https://github.com/python-attrs/attrs/issues/215
196193
self.java_name = java_name
197194
self.padding = padding
198195
self.digest = digest
@@ -228,12 +225,11 @@ def __init__(
228225
self,
229226
java_name, # type: Text
230227
mode # type: Callable
231-
):
228+
): # noqa=D107
232229
# type: (...) -> None
233-
"""Workaround pending resolution of attrs/mypy interaction.
234-
https://github.com/python/mypy/issues/2088
235-
https://github.com/python-attrs/attrs/issues/215
236-
"""
230+
# Workaround pending resolution of attrs/mypy interaction.
231+
# https://github.com/python/mypy/issues/2088
232+
# https://github.com/python-attrs/attrs/issues/215
237233
self.java_name = java_name
238234
self.mode = mode
239235
attr.validate(self)
@@ -262,12 +258,11 @@ def __init__(
262258
self,
263259
java_name, # type: Text
264260
cipher # type: Callable
265-
):
261+
): # noqa=D107
266262
# type: (...) -> None
267-
"""Workaround pending resolution of attrs/mypy interaction.
268-
https://github.com/python/mypy/issues/2088
269-
https://github.com/python-attrs/attrs/issues/215
270-
"""
263+
# Workaround pending resolution of attrs/mypy interaction.
264+
# https://github.com/python/mypy/issues/2088
265+
# https://github.com/python-attrs/attrs/issues/215
271266
self.java_name = java_name
272267
self.cipher = cipher
273268
attr.validate(self)

src/dynamodb_encryption_sdk/internal/utils.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,11 @@ def __init__(
6868
self,
6969
client, # type: botocore.client.BaseClient
7070
auto_refresh_table_indexes # type: bool
71-
):
71+
): # noqa=D107
7272
# type: (...) -> None
73-
"""Workaround pending resolution of attrs/mypy interaction.
74-
https://github.com/python/mypy/issues/2088
75-
https://github.com/python-attrs/attrs/issues/215
76-
"""
73+
# Workaround pending resolution of attrs/mypy interaction.
74+
# https://github.com/python/mypy/issues/2088
75+
# https://github.com/python-attrs/attrs/issues/215
7776
self._client = client
7877
self._auto_refresh_table_indexes = auto_refresh_table_indexes
7978
attr.validate(self)

src/dynamodb_encryption_sdk/material_providers/aws_kms.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,11 @@ def __init__(
8989
description, # type: Text
9090
algorithm, # type: Text
9191
length # type: int
92-
):
92+
): # noqa=D107
9393
# type: (...) -> None
94-
"""Workaround pending resolution of attrs/mypy interaction.
95-
https://github.com/python/mypy/issues/2088
96-
https://github.com/python-attrs/attrs/issues/215
97-
"""
94+
# Workaround pending resolution of attrs/mypy interaction.
95+
# https://github.com/python/mypy/issues/2088
96+
# https://github.com/python-attrs/attrs/issues/215
9897
self.description = description
9998
self.algorithm = algorithm
10099
self.length = length
@@ -183,12 +182,11 @@ def __init__(
183182
grant_tokens=None, # type: Optional[Tuple[Text]]
184183
material_description=None, # type: Optional[Dict[Text, Text]]
185184
regional_clients=None # type: Optional[Dict[Text, botocore.client.BaseClient]]
186-
):
185+
): # noqa=D107
187186
# type: (...) -> None
188-
"""Workaround pending resolution of attrs/mypy interaction.
189-
https://github.com/python/mypy/issues/2088
190-
https://github.com/python-attrs/attrs/issues/215
191-
"""
187+
# Workaround pending resolution of attrs/mypy interaction.
188+
# https://github.com/python/mypy/issues/2088
189+
# https://github.com/python-attrs/attrs/issues/215
192190
if botocore_session is None:
193191
botocore_session = botocore.session.Session()
194192
if grant_tokens is None:

src/dynamodb_encryption_sdk/material_providers/most_recent.py

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class TtlActions(Enum):
5050

5151

5252
def _min_capacity_validator(instance, attribute, value):
53+
# pylint: disable=unused-argument
5354
"""Attrs validator to require that value is at least 1."""
5455
if value < 1:
5556
raise ValueError('Cache capacity must be at least 1')
@@ -64,12 +65,11 @@ class BasicCache(object):
6465
_min_capacity_validator
6566
))
6667

67-
def __init__(self, capacity):
68+
def __init__(self, capacity): # noqa=D107
6869
# type: (int) -> None
69-
"""Workaround pending resolution of attrs/mypy interaction.
70-
https://github.com/python/mypy/issues/2088
71-
https://github.com/python-attrs/attrs/issues/215
72-
"""
70+
# Workaround pending resolution of attrs/mypy interaction.
71+
# https://github.com/python/mypy/issues/2088
72+
# https://github.com/python-attrs/attrs/issues/215
7373
self.capacity = capacity
7474
attr.validate(self)
7575
self.__attrs_post_init__()
@@ -114,7 +114,7 @@ def clear(self):
114114
# type: () -> None
115115
"""Clear the cache."""
116116
with self._cache_lock:
117-
self._cache = OrderedDict() # type: OrderedDict[Any, Any]
117+
self._cache = OrderedDict() # type: OrderedDict[Any, Any] # pylint: disable=attribute-defined-outside-init
118118

119119

120120
@attr.s(init=False)
@@ -140,12 +140,11 @@ def __init__(
140140
provider_store, # type: ProviderStore
141141
material_name, # type: Text
142142
version_ttl # type: float
143-
):
143+
): # noqa=D107
144144
# type: (...) -> None
145-
"""Workaround pending resolution of attrs/mypy interaction.
146-
https://github.com/python/mypy/issues/2088
147-
https://github.com/python-attrs/attrs/issues/215
148-
"""
145+
# Workaround pending resolution of attrs/mypy interaction.
146+
# https://github.com/python/mypy/issues/2088
147+
# https://github.com/python-attrs/attrs/issues/215
149148
self._provider_store = provider_store
150149
self._material_name = material_name
151150
self._version_ttl = version_ttl
@@ -155,8 +154,10 @@ def __init__(
155154
def __attrs_post_init__(self):
156155
# type: () -> None
157156
"""Initialize the cache."""
158-
self._lock = Lock()
159-
self._cache = BasicCache(1000)
157+
self._version = None # type: int # pylint: disable=attribute-defined-outside-init
158+
self._last_updated = None # type: float # pylint: disable=attribute-defined-outside-init
159+
self._lock = Lock() # pylint: disable=attribute-defined-outside-init
160+
self._cache = BasicCache(1000) # pylint: disable=attribute-defined-outside-init
160161
self.refresh()
161162

162163
def decryption_materials(self, encryption_context):
@@ -280,12 +281,9 @@ def encryption_materials(self, encryption_context):
280281
except KeyError:
281282
ttl_action = TtlActions.EXPIRED
282283

283-
if ttl_action is TtlActions.GRACE_PERIOD:
284-
# Just get the latest local version if we cannot acquire the lock.
285-
allow_local = True
286-
else:
287-
# Block until we can acquire the lock.
288-
allow_local = False
284+
# Just get the latest local version if we cannot acquire the lock.
285+
# Otherwise, block until we can acquire the lock.
286+
allow_local = bool(ttl_action is TtlActions.GRACE_PERIOD)
289287

290288
provider = self._get_most_recent_version(allow_local)
291289

@@ -296,5 +294,5 @@ def refresh(self):
296294
"""Clear all local caches for this provider."""
297295
with self._lock:
298296
self._cache.clear()
299-
self._version = None # type: int
300-
self._last_updated = None # type: float
297+
self._version = None # type: int # pylint: disable=attribute-defined-outside-init
298+
self._last_updated = None # type: float # pylint: disable=attribute-defined-outside-init

0 commit comments

Comments
 (0)