Skip to content

Commit b248c52

Browse files
committed
cleaning up attrs/mypy workaround comments to remove them from rendered docs
1 parent 10f7731 commit b248c52

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
@@ -125,13 +125,12 @@ def __init__(
125125
key, # type: bytes
126126
algorithm, # type: Text
127127
key_type, # type: EncryptionKeyType
128-
key_encoding # type: KeyEncodingType
129-
):
128+
key_encoding, # type: KeyEncodingType
129+
): # noqa=D107
130130
# type: (...) -> None
131-
"""Workaround pending resolution of attrs/mypy interaction.
132-
https://github.com/python/mypy/issues/2088
133-
https://github.com/python-attrs/attrs/issues/215
134-
"""
131+
# Workaround pending resolution of attrs/mypy interaction.
132+
# https://github.com/python/mypy/issues/2088
133+
# https://github.com/python-attrs/attrs/issues/215
135134
self.key = key
136135
self._algorithm = algorithm
137136
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
@@ -62,12 +62,11 @@ def __init__(
6262
materials_provider, # type: CryptographicMaterialsProvider
6363
attribute_actions, # type: AttributeActions
6464
table_info_cache # type: TableInfoCache
65-
):
65+
): # noqa=D107
6666
# type: (...) -> None
67-
"""Workaround pending resolution of attrs/mypy interaction.
68-
https://github.com/python/mypy/issues/2088
69-
https://github.com/python-attrs/attrs/issues/215
70-
"""
67+
# Workaround pending resolution of attrs/mypy interaction.
68+
# https://github.com/python/mypy/issues/2088
69+
# https://github.com/python-attrs/attrs/issues/215
7170
self._collection = collection
7271
self._materials_provider = materials_provider
7372
self._attribute_actions = attribute_actions
@@ -173,12 +172,11 @@ def __init__(
173172
materials_provider, # type: CryptographicMaterialsProvider
174173
attribute_actions=None, # type: Optional[AttributeActions]
175174
auto_refresh_table_indexes=True # type: Optional[bool]
176-
):
175+
): # noqa=D107
177176
# type: (...) -> None
178-
"""Workaround pending resolution of attrs/mypy interaction.
179-
https://github.com/python/mypy/issues/2088
180-
https://github.com/python-attrs/attrs/issues/215
181-
"""
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
182180
if attribute_actions is None:
183181
attribute_actions = AttributeActions()
184182

src/dynamodb_encryption_sdk/encrypted/table.py

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

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,11 @@ def __init__(
104104
java_name, # type: Text
105105
algorithm_type, # type: Callable
106106
hash_type # type: Callable
107-
):
107+
): # noqa=D107
108108
# type: (...) -> None
109-
"""Workaround pending resolution of attrs/mypy interaction.
110-
https://github.com/python/mypy/issues/2088
111-
https://github.com/python-attrs/attrs/issues/215
112-
"""
109+
# Workaround pending resolution of attrs/mypy interaction.
110+
# https://github.com/python/mypy/issues/2088
111+
# https://github.com/python-attrs/attrs/issues/215
113112
self.java_name = java_name
114113
self.algorithm_type = algorithm_type
115114
self.hash_type = hash_type
@@ -217,12 +216,11 @@ def __init__(
217216
algorithm_type,
218217
hash_type, # type: Callable
219218
padding_type # type: Callable
220-
):
219+
): # noqa=D107
221220
# type: (...) -> None
222-
"""Workaround pending resolution of attrs/mypy interaction.
223-
https://github.com/python/mypy/issues/2088
224-
https://github.com/python-attrs/attrs/issues/215
225-
"""
221+
# Workaround pending resolution of attrs/mypy interaction.
222+
# https://github.com/python/mypy/issues/2088
223+
# https://github.com/python-attrs/attrs/issues/215
226224
self.java_name = java_name
227225
self.algorithm_type = algorithm_type
228226
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)
@@ -184,12 +182,11 @@ def __init__(
184182
digest, # type: Callable
185183
mgf, # type: Callable
186184
mgf_digest # type: Callable
187-
):
185+
): # noqa=D107
188186
# type: (...) -> None
189-
"""Workaround pending resolution of attrs/mypy interaction.
190-
https://github.com/python/mypy/issues/2088
191-
https://github.com/python-attrs/attrs/issues/215
192-
"""
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
193190
self.java_name = java_name
194191
self.padding = padding
195192
self.digest = digest
@@ -225,12 +222,11 @@ def __init__(
225222
self,
226223
java_name, # type: Text
227224
mode # type: Callable
228-
):
225+
): # noqa=D107
229226
# type: (...) -> None
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
233-
"""
227+
# Workaround pending resolution of attrs/mypy interaction.
228+
# https://github.com/python/mypy/issues/2088
229+
# https://github.com/python-attrs/attrs/issues/215
234230
self.java_name = java_name
235231
self.mode = mode
236232
attr.validate(self)
@@ -259,12 +255,11 @@ def __init__(
259255
self,
260256
java_name, # type: Text
261257
cipher # type: Callable
262-
):
258+
): # noqa=D107
263259
# type: (...) -> None
264-
"""Workaround pending resolution of attrs/mypy interaction.
265-
https://github.com/python/mypy/issues/2088
266-
https://github.com/python-attrs/attrs/issues/215
267-
"""
260+
# Workaround pending resolution of attrs/mypy interaction.
261+
# https://github.com/python/mypy/issues/2088
262+
# https://github.com/python-attrs/attrs/issues/215
268263
self.java_name = java_name
269264
self.cipher = cipher
270265
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
@@ -49,6 +49,7 @@ class TtlActions(Enum):
4949

5050

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

66-
def __init__(self, capacity):
67+
def __init__(self, capacity): # noqa=D107
6768
# type: (int) -> None
68-
"""Workaround pending resolution of attrs/mypy interaction.
69-
https://github.com/python/mypy/issues/2088
70-
https://github.com/python-attrs/attrs/issues/215
71-
"""
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
7272
self.capacity = capacity
7373
attr.validate(self)
7474
self.__attrs_post_init__()
@@ -109,7 +109,7 @@ def clear(self):
109109
# type: () -> None
110110
"""Clear the cache."""
111111
with self._cache_lock:
112-
self._cache = OrderedDict() # type: OrderedDict[Any, Any]
112+
self._cache = OrderedDict() # type: OrderedDict[Any, Any] # pylint: disable=attribute-defined-outside-init
113113

114114

115115
@attr.s(init=False)
@@ -136,12 +136,11 @@ def __init__(
136136
provider_store, # type: ProviderStore
137137
material_name, # type: Text
138138
version_ttl # type: float
139-
):
139+
): # noqa=D107
140140
# type: (...) -> None
141-
"""Workaround pending resolution of attrs/mypy interaction.
142-
https://github.com/python/mypy/issues/2088
143-
https://github.com/python-attrs/attrs/issues/215
144-
"""
141+
# Workaround pending resolution of attrs/mypy interaction.
142+
# https://github.com/python/mypy/issues/2088
143+
# https://github.com/python-attrs/attrs/issues/215
145144
self._provider_store = provider_store
146145
self._material_name = material_name
147146
self._version_ttl = version_ttl
@@ -151,8 +150,10 @@ def __init__(
151150
def __attrs_post_init__(self):
152151
# type: () -> None
153152
"""Initialize the cache."""
154-
self._lock = Lock()
155-
self._cache = BasicCache(1000)
153+
self._version = None # type: int # pylint: disable=attribute-defined-outside-init
154+
self._last_updated = None # type: float # pylint: disable=attribute-defined-outside-init
155+
self._lock = Lock() # pylint: disable=attribute-defined-outside-init
156+
self._cache = BasicCache(1000) # pylint: disable=attribute-defined-outside-init
156157
self.refresh()
157158

158159
def decryption_materials(self, encryption_context):
@@ -278,12 +279,9 @@ def encryption_materials(self, encryption_context):
278279
except KeyError:
279280
ttl_action = TtlActions.EXPIRED
280281

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

288286
provider = self._get_most_recent_version(allow_local)
289287

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

0 commit comments

Comments
 (0)