Skip to content

cleaning up attrs/mypy workaround comments to remove them from rendered docs #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/dynamodb_encryption_sdk/delegated_keys/jce.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,12 @@ def __init__(
key, # type: bytes
algorithm, # type: Text
key_type, # type: EncryptionKeyType
key_encoding # type: KeyEncodingType
):
key_encoding, # type: KeyEncodingType
): # noqa=D107
# type: (...) -> None
"""Workaround pending resolution of attrs/mypy interaction.
https://github.com/python/mypy/issues/2088
https://github.com/python-attrs/attrs/issues/215
"""
# Workaround pending resolution of attrs/mypy interaction.
# https://github.com/python/mypy/issues/2088
# https://github.com/python-attrs/attrs/issues/215
self.key = key
self._algorithm = algorithm
self._key_type = key_type
Expand Down
9 changes: 4 additions & 5 deletions src/dynamodb_encryption_sdk/encrypted/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,11 @@ def __init__(
materials_provider, # type: CryptographicMaterialsProvider
encryption_context, # type: EncryptionContext
attribute_actions # type: AttributeActions
):
): # noqa=D107
# type: (...) -> None
"""Workaround pending resolution of attrs/mypy interaction.
https://github.com/python/mypy/issues/2088
https://github.com/python-attrs/attrs/issues/215
"""
# Workaround pending resolution of attrs/mypy interaction.
# https://github.com/python/mypy/issues/2088
# https://github.com/python-attrs/attrs/issues/215
self.materials_provider = materials_provider
self.encryption_context = encryption_context
self.attribute_actions = attribute_actions
Expand Down
18 changes: 8 additions & 10 deletions src/dynamodb_encryption_sdk/encrypted/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,11 @@ def __init__(
paginator, # type: botocore.paginate.Paginator
decrypt_method, # type: Callable
crypto_config_method # type: Callable
):
): # noqa=D107
# type: (...) -> None
"""Workaround pending resolution of attrs/mypy interaction.
https://github.com/python/mypy/issues/2088
https://github.com/python-attrs/attrs/issues/215
"""
# Workaround pending resolution of attrs/mypy interaction.
# https://github.com/python/mypy/issues/2088
# https://github.com/python-attrs/attrs/issues/215
self._paginator = paginator
self._decrypt_method = decrypt_method
self._crypto_config_method = crypto_config_method
Expand Down Expand Up @@ -172,12 +171,11 @@ def __init__(
attribute_actions=None, # type: Optional[AttributeActions]
auto_refresh_table_indexes=True, # type: Optional[bool]
expect_standard_dictionaries=False # type: Optional[bool]
):
): # noqa=D107
# type: (...) -> None
"""Workaround pending resolution of attrs/mypy interaction.
https://github.com/python/mypy/issues/2088
https://github.com/python-attrs/attrs/issues/215
"""
# Workaround pending resolution of attrs/mypy interaction.
# https://github.com/python/mypy/issues/2088
# https://github.com/python-attrs/attrs/issues/215
if attribute_actions is None:
attribute_actions = AttributeActions()

Expand Down
18 changes: 8 additions & 10 deletions src/dynamodb_encryption_sdk/encrypted/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,11 @@ def __init__(
materials_provider, # type: CryptographicMaterialsProvider
attribute_actions, # type: AttributeActions
table_info_cache # type: TableInfoCache
):
): # noqa=D107
# type: (...) -> None
"""Workaround pending resolution of attrs/mypy interaction.
https://github.com/python/mypy/issues/2088
https://github.com/python-attrs/attrs/issues/215
"""
# Workaround pending resolution of attrs/mypy interaction.
# https://github.com/python/mypy/issues/2088
# https://github.com/python-attrs/attrs/issues/215
self._collection = collection
self._materials_provider = materials_provider
self._attribute_actions = attribute_actions
Expand Down Expand Up @@ -173,12 +172,11 @@ def __init__(
materials_provider, # type: CryptographicMaterialsProvider
attribute_actions=None, # type: Optional[AttributeActions]
auto_refresh_table_indexes=True # type: Optional[bool]
):
): # noqa=D107
# type: (...) -> None
"""Workaround pending resolution of attrs/mypy interaction.
https://github.com/python/mypy/issues/2088
https://github.com/python-attrs/attrs/issues/215
"""
# Workaround pending resolution of attrs/mypy interaction.
# https://github.com/python/mypy/issues/2088
# https://github.com/python-attrs/attrs/issues/215
if attribute_actions is None:
attribute_actions = AttributeActions()

Expand Down
9 changes: 4 additions & 5 deletions src/dynamodb_encryption_sdk/encrypted/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,11 @@ def __init__(
table_info=None, # type: Optional[TableInfo]
attribute_actions=None, # type: Optional[AttributeActions]
auto_refresh_table_indexes=True # type: Optional[bool]
):
): # noqa=D107
# type: (...) -> None
"""Workaround pending resolution of attrs/mypy interaction.
https://github.com/python/mypy/issues/2088
https://github.com/python-attrs/attrs/issues/215
"""
# Workaround pending resolution of attrs/mypy interaction.
# https://github.com/python/mypy/issues/2088
# https://github.com/python-attrs/attrs/issues/215
if attribute_actions is None:
attribute_actions = AttributeActions()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,11 @@ def __init__(
java_name, # type: Text
algorithm_type, # type: Callable
hash_type # type: Callable
):
): # noqa=D107
# type: (...) -> None
"""Workaround pending resolution of attrs/mypy interaction.
https://github.com/python/mypy/issues/2088
https://github.com/python-attrs/attrs/issues/215
"""
# Workaround pending resolution of attrs/mypy interaction.
# https://github.com/python/mypy/issues/2088
# https://github.com/python-attrs/attrs/issues/215
self.java_name = java_name
self.algorithm_type = algorithm_type
self.hash_type = hash_type
Expand Down Expand Up @@ -217,12 +216,11 @@ def __init__(
algorithm_type,
hash_type, # type: Callable
padding_type # type: Callable
):
): # noqa=D107
# type: (...) -> None
"""Workaround pending resolution of attrs/mypy interaction.
https://github.com/python/mypy/issues/2088
https://github.com/python-attrs/attrs/issues/215
"""
# Workaround pending resolution of attrs/mypy interaction.
# https://github.com/python/mypy/issues/2088
# https://github.com/python-attrs/attrs/issues/215
self.java_name = java_name
self.algorithm_type = algorithm_type
self.hash_type = hash_type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,11 @@ def __init__(
cipher, # type: JavaEncryptionAlgorithm
mode, # type: JavaMode
padding # type: JavaPadding
):
): # noqa=D107
# type: (...) -> None
"""Workaround pending resolution of attrs/mypy interaction.
https://github.com/python/mypy/issues/2088
https://github.com/python-attrs/attrs/issues/215
"""
# Workaround pending resolution of attrs/mypy interaction.
# https://github.com/python/mypy/issues/2088
# https://github.com/python-attrs/attrs/issues/215
self.cipher = cipher
self.mode = mode
self.padding = padding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,11 @@ def __init__(
self,
java_name, # type: Text
padding # type: Callable
):
): # noqa=D107
# type: (...) -> None
"""Workaround pending resolution of attrs/mypy interaction.
https://github.com/python/mypy/issues/2088
https://github.com/python-attrs/attrs/issues/215
"""
# Workaround pending resolution of attrs/mypy interaction.
# https://github.com/python/mypy/issues/2088
# https://github.com/python-attrs/attrs/issues/215
self.java_name = java_name
self.padding = padding
attr.validate(self)
Expand All @@ -139,12 +138,11 @@ def __init__(
self,
java_name, # type: Text
padding # type: Callable
):
): # noqa=D107
# type: (...) -> None
"""Workaround pending resolution of attrs/mypy interaction.
https://github.com/python/mypy/issues/2088
https://github.com/python-attrs/attrs/issues/215
"""
# Workaround pending resolution of attrs/mypy interaction.
# https://github.com/python/mypy/issues/2088
# https://github.com/python-attrs/attrs/issues/215
self.java_name = java_name
self.padding = padding
attr.validate(self)
Expand Down Expand Up @@ -184,12 +182,11 @@ def __init__(
digest, # type: Callable
mgf, # type: Callable
mgf_digest # type: Callable
):
): # noqa=D107
# type: (...) -> None
"""Workaround pending resolution of attrs/mypy interaction.
https://github.com/python/mypy/issues/2088
https://github.com/python-attrs/attrs/issues/215
"""
# Workaround pending resolution of attrs/mypy interaction.
# https://github.com/python/mypy/issues/2088
# https://github.com/python-attrs/attrs/issues/215
self.java_name = java_name
self.padding = padding
self.digest = digest
Expand Down Expand Up @@ -225,12 +222,11 @@ def __init__(
self,
java_name, # type: Text
mode # type: Callable
):
): # noqa=D107
# type: (...) -> None
"""Workaround pending resolution of attrs/mypy interaction.
https://github.com/python/mypy/issues/2088
https://github.com/python-attrs/attrs/issues/215
"""
# Workaround pending resolution of attrs/mypy interaction.
# https://github.com/python/mypy/issues/2088
# https://github.com/python-attrs/attrs/issues/215
self.java_name = java_name
self.mode = mode
attr.validate(self)
Expand Down Expand Up @@ -259,12 +255,11 @@ def __init__(
self,
java_name, # type: Text
cipher # type: Callable
):
): # noqa=D107
# type: (...) -> None
"""Workaround pending resolution of attrs/mypy interaction.
https://github.com/python/mypy/issues/2088
https://github.com/python-attrs/attrs/issues/215
"""
# Workaround pending resolution of attrs/mypy interaction.
# https://github.com/python/mypy/issues/2088
# https://github.com/python-attrs/attrs/issues/215
self.java_name = java_name
self.cipher = cipher
attr.validate(self)
Expand Down
9 changes: 4 additions & 5 deletions src/dynamodb_encryption_sdk/internal/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,11 @@ def __init__(
self,
client, # type: botocore.client.BaseClient
auto_refresh_table_indexes # type: bool
):
): # noqa=D107
# type: (...) -> None
"""Workaround pending resolution of attrs/mypy interaction.
https://github.com/python/mypy/issues/2088
https://github.com/python-attrs/attrs/issues/215
"""
# Workaround pending resolution of attrs/mypy interaction.
# https://github.com/python/mypy/issues/2088
# https://github.com/python-attrs/attrs/issues/215
self._client = client
self._auto_refresh_table_indexes = auto_refresh_table_indexes
attr.validate(self)
Expand Down
18 changes: 8 additions & 10 deletions src/dynamodb_encryption_sdk/material_providers/aws_kms.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,11 @@ def __init__(
description, # type: Text
algorithm, # type: Text
length # type: int
):
): # noqa=D107
# type: (...) -> None
"""Workaround pending resolution of attrs/mypy interaction.
https://github.com/python/mypy/issues/2088
https://github.com/python-attrs/attrs/issues/215
"""
# Workaround pending resolution of attrs/mypy interaction.
# https://github.com/python/mypy/issues/2088
# https://github.com/python-attrs/attrs/issues/215
self.description = description
self.algorithm = algorithm
self.length = length
Expand Down Expand Up @@ -183,12 +182,11 @@ def __init__(
grant_tokens=None, # type: Optional[Tuple[Text]]
material_description=None, # type: Optional[Dict[Text, Text]]
regional_clients=None # type: Optional[Dict[Text, botocore.client.BaseClient]]
):
): # noqa=D107
# type: (...) -> None
"""Workaround pending resolution of attrs/mypy interaction.
https://github.com/python/mypy/issues/2088
https://github.com/python-attrs/attrs/issues/215
"""
# Workaround pending resolution of attrs/mypy interaction.
# https://github.com/python/mypy/issues/2088
# https://github.com/python-attrs/attrs/issues/215
if botocore_session is None:
botocore_session = botocore.session.Session()
if grant_tokens is None:
Expand Down
40 changes: 19 additions & 21 deletions src/dynamodb_encryption_sdk/material_providers/most_recent.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class TtlActions(Enum):


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

def __init__(self, capacity):
def __init__(self, capacity): # noqa=D107
# type: (int) -> None
"""Workaround pending resolution of attrs/mypy interaction.
https://github.com/python/mypy/issues/2088
https://github.com/python-attrs/attrs/issues/215
"""
# Workaround pending resolution of attrs/mypy interaction.
# https://github.com/python/mypy/issues/2088
# https://github.com/python-attrs/attrs/issues/215
self.capacity = capacity
attr.validate(self)
self.__attrs_post_init__()
Expand Down Expand Up @@ -109,7 +109,7 @@ def clear(self):
# type: () -> None
"""Clear the cache."""
with self._cache_lock:
self._cache = OrderedDict() # type: OrderedDict[Any, Any]
self._cache = OrderedDict() # type: OrderedDict[Any, Any] # pylint: disable=attribute-defined-outside-init


@attr.s(init=False)
Expand All @@ -136,12 +136,11 @@ def __init__(
provider_store, # type: ProviderStore
material_name, # type: Text
version_ttl # type: float
):
): # noqa=D107
# type: (...) -> None
"""Workaround pending resolution of attrs/mypy interaction.
https://github.com/python/mypy/issues/2088
https://github.com/python-attrs/attrs/issues/215
"""
# Workaround pending resolution of attrs/mypy interaction.
# https://github.com/python/mypy/issues/2088
# https://github.com/python-attrs/attrs/issues/215
self._provider_store = provider_store
self._material_name = material_name
self._version_ttl = version_ttl
Expand All @@ -151,8 +150,10 @@ def __init__(
def __attrs_post_init__(self):
# type: () -> None
"""Initialize the cache."""
self._lock = Lock()
self._cache = BasicCache(1000)
self._version = None # type: int # pylint: disable=attribute-defined-outside-init
self._last_updated = None # type: float # pylint: disable=attribute-defined-outside-init
self._lock = Lock() # pylint: disable=attribute-defined-outside-init
self._cache = BasicCache(1000) # pylint: disable=attribute-defined-outside-init
self.refresh()

def decryption_materials(self, encryption_context):
Expand Down Expand Up @@ -278,12 +279,9 @@ def encryption_materials(self, encryption_context):
except KeyError:
ttl_action = TtlActions.EXPIRED

if ttl_action is TtlActions.GRACE_PERIOD:
# Just get the latest local version if we cannot acquire the lock.
allow_local = True
else:
# Block until we can acquire the lock.
allow_local = False
# Just get the latest local version if we cannot acquire the lock.
# Otherwise, block until we can acquire the lock.
allow_local = bool(ttl_action is TtlActions.GRACE_PERIOD)

provider = self._get_most_recent_version(allow_local)

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