16
16
import attr
17
17
import botocore
18
18
19
+ try : # Python 3.5.0 and 3.5.1 have incompatible typing modules
20
+ from typing import Any , Callable , Dict , Optional # noqa pylint: disable=unused-import
21
+ except ImportError : # pragma: no cover
22
+ # We only actually need these imports when running the mypy checks
23
+ pass
24
+
19
25
from dynamodb_encryption_sdk .internal .utils import (
20
26
crypto_config_from_cache , crypto_config_from_kwargs ,
21
27
decrypt_batch_get_item , decrypt_get_item , decrypt_multi_get ,
30
36
__all__ = ('EncryptedClient' ,)
31
37
32
38
33
- @attr .s
39
+ @attr .s ( init = False )
34
40
class EncryptedPaginator (object ):
35
41
"""Paginator that decrypts returned items before returning them.
36
42
@@ -44,6 +50,22 @@ class EncryptedPaginator(object):
44
50
_decrypt_method = attr .ib ()
45
51
_crypto_config_method = attr .ib (validator = callable_validator )
46
52
53
+ def __init__ (
54
+ self ,
55
+ paginator , # type: botocore.paginate.Paginator
56
+ decrypt_method , # type: Callable
57
+ crypto_config_method # type: Callable
58
+ ):
59
+ # 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
+ """
64
+ self ._paginator = paginator
65
+ self ._decrypt_method = decrypt_method
66
+ self ._crypto_config_method = crypto_config_method
67
+ attr .validate (self )
68
+
47
69
@_decrypt_method .validator
48
70
def validate_decrypt_method (self , attribute , value ):
49
71
# pylint: disable=unused-argument
@@ -84,7 +106,7 @@ def paginate(self, **kwargs):
84
106
yield page
85
107
86
108
87
- @attr .s
109
+ @attr .s ( init = False )
88
110
class EncryptedClient (object ):
89
111
# pylint: disable=too-few-public-methods,too-many-instance-attributes
90
112
"""High-level helper class to provide a familiar interface to encrypted tables.
@@ -143,6 +165,30 @@ class EncryptedClient(object):
143
165
default = False
144
166
)
145
167
168
+ def __init__ (
169
+ self ,
170
+ client , # type: botocore.client.BaseClient
171
+ materials_provider , # type: CryptographicMaterialsProvider
172
+ attribute_actions = None , # type: Optional[AttributeActions]
173
+ auto_refresh_table_indexes = True , # type: Optional[bool]
174
+ expect_standard_dictionaries = False # type: Optional[bool]
175
+ ):
176
+ # 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
+ """
181
+ if attribute_actions is None :
182
+ attribute_actions = AttributeActions ()
183
+
184
+ self ._client = client
185
+ self ._materials_provider = materials_provider
186
+ self ._attribute_actions = attribute_actions
187
+ self ._auto_refresh_table_indexes = auto_refresh_table_indexes
188
+ self ._expect_standard_dictionaries = expect_standard_dictionaries
189
+ attr .validate (self )
190
+ self .__attrs_post_init__ ()
191
+
146
192
def __attrs_post_init__ (self ):
147
193
"""Set up the table info cache and translation methods."""
148
194
if self ._expect_standard_dictionaries :
0 commit comments