diff --git a/src/dynamodb_encryption_sdk/delegated_keys/__init__.py b/src/dynamodb_encryption_sdk/delegated_keys/__init__.py index d301543a..ac0aa734 100644 --- a/src/dynamodb_encryption_sdk/delegated_keys/__init__.py +++ b/src/dynamodb_encryption_sdk/delegated_keys/__init__.py @@ -12,18 +12,12 @@ # language governing permissions and limitations under the License. """Delegated keys.""" import abc +from typing import Dict, Optional, Text import six from dynamodb_encryption_sdk.identifiers import EncryptionKeyType # noqa pylint: disable=unused-import -try: # Python 3.5.0 and 3.5.1 have incompatible typing modules - from typing import Dict, Optional, Text # noqa pylint: disable=unused-import -except ImportError: # pragma: no cover - # We only actually need these imports when running the mypy checks - pass - - __all__ = ("DelegatedKey",) diff --git a/src/dynamodb_encryption_sdk/delegated_keys/jce.py b/src/dynamodb_encryption_sdk/delegated_keys/jce.py index 4edc6b2c..c2be9b5c 100644 --- a/src/dynamodb_encryption_sdk/delegated_keys/jce.py +++ b/src/dynamodb_encryption_sdk/delegated_keys/jce.py @@ -15,6 +15,7 @@ import logging import os +from typing import Dict, Optional, Text import attr import six @@ -28,13 +29,6 @@ from . import DelegatedKey -try: # Python 3.5.0 and 3.5.1 have incompatible typing modules - from typing import Dict, Optional, Text # noqa pylint: disable=unused-import -except ImportError: # pragma: no cover - # We only actually need these imports when running the mypy checks - pass - - __all__ = ("JceNameLocalDelegatedKey",) _LOGGER = logging.getLogger(LOGGER_NAME) diff --git a/src/dynamodb_encryption_sdk/encrypted/__init__.py b/src/dynamodb_encryption_sdk/encrypted/__init__.py index e3e89ec1..d03f3f4a 100644 --- a/src/dynamodb_encryption_sdk/encrypted/__init__.py +++ b/src/dynamodb_encryption_sdk/encrypted/__init__.py @@ -21,13 +21,6 @@ from dynamodb_encryption_sdk.materials import CryptographicMaterials # noqa pylint: disable=unused-import from dynamodb_encryption_sdk.structures import AttributeActions, EncryptionContext -try: # Python 3.5.0 and 3.5.1 have incompatible typing modules - from typing import Dict # noqa pylint: disable=unused-import -except ImportError: # pragma: no cover - # We only actually need these imports when running the mypy checks - pass - - __all__ = ("CryptoConfig",) diff --git a/src/dynamodb_encryption_sdk/encrypted/client.py b/src/dynamodb_encryption_sdk/encrypted/client.py index d3858a00..e13533f3 100644 --- a/src/dynamodb_encryption_sdk/encrypted/client.py +++ b/src/dynamodb_encryption_sdk/encrypted/client.py @@ -12,6 +12,7 @@ # language governing permissions and limitations under the License. """High-level helper class to provide a familiar interface to encrypted tables.""" from functools import partial +from typing import Any, Callable, Dict, Iterator, Optional import attr import botocore @@ -34,13 +35,6 @@ from .item import decrypt_dynamodb_item, decrypt_python_item, encrypt_dynamodb_item, encrypt_python_item -try: # Python 3.5.0 and 3.5.1 have incompatible typing modules - from typing import Any, Callable, Dict, Iterator, Optional # noqa pylint: disable=unused-import -except ImportError: # pragma: no cover - # We only actually need these imports when running the mypy checks - pass - - __all__ = ("EncryptedClient", "EncryptedPaginator") diff --git a/src/dynamodb_encryption_sdk/encrypted/item.py b/src/dynamodb_encryption_sdk/encrypted/item.py index b491a34a..33c109cf 100644 --- a/src/dynamodb_encryption_sdk/encrypted/item.py +++ b/src/dynamodb_encryption_sdk/encrypted/item.py @@ -11,14 +11,9 @@ # ANY KIND, either express or implied. See the License for the specific # language governing permissions and limitations under the License. """Top-level functions for encrypting and decrypting DynamoDB items.""" -try: # Python 3.5.0 and 3.5.1 have incompatible typing modules - from dynamodb_encryption_sdk.internal import dynamodb_types # noqa pylint: disable=unused-import -except ImportError: # pragma: no cover - # We only actually need these imports when running the mypy checks - pass - from dynamodb_encryption_sdk.exceptions import DecryptionError, EncryptionError from dynamodb_encryption_sdk.identifiers import CryptoAction +from dynamodb_encryption_sdk.internal import dynamodb_types from dynamodb_encryption_sdk.internal.crypto.authentication import sign_item, verify_item_signature from dynamodb_encryption_sdk.internal.crypto.encryption import decrypt_attribute, encrypt_attribute from dynamodb_encryption_sdk.internal.formatting.material_description import ( diff --git a/src/dynamodb_encryption_sdk/encrypted/resource.py b/src/dynamodb_encryption_sdk/encrypted/resource.py index f5ecf6c6..f040ea7a 100644 --- a/src/dynamodb_encryption_sdk/encrypted/resource.py +++ b/src/dynamodb_encryption_sdk/encrypted/resource.py @@ -12,6 +12,7 @@ # language governing permissions and limitations under the License. """High-level helper class to provide a familiar interface to encrypted tables.""" from functools import partial +from typing import Optional import attr from boto3.resources.base import ServiceResource @@ -29,13 +30,6 @@ from .item import decrypt_python_item, encrypt_python_item from .table import EncryptedTable -try: # Python 3.5.0 and 3.5.1 have incompatible typing modules - from typing import Optional # noqa pylint: disable=unused-import -except ImportError: # pragma: no cover - # We only actually need these imports when running the mypy checks - pass - - __all__ = ("EncryptedResource", "EncryptedTablesCollectionManager") diff --git a/src/dynamodb_encryption_sdk/encrypted/table.py b/src/dynamodb_encryption_sdk/encrypted/table.py index 1cef41a0..98386b81 100644 --- a/src/dynamodb_encryption_sdk/encrypted/table.py +++ b/src/dynamodb_encryption_sdk/encrypted/table.py @@ -12,6 +12,7 @@ # language governing permissions and limitations under the License. """High-level helper class to provide a familiar interface to encrypted tables.""" from functools import partial +from typing import Optional import attr from boto3.dynamodb.table import BatchWriter @@ -30,13 +31,6 @@ from .client import EncryptedClient from .item import decrypt_python_item, encrypt_python_item -try: # Python 3.5.0 and 3.5.1 have incompatible typing modules - from typing import Optional # noqa pylint: disable=unused-import -except ImportError: # pragma: no cover - # We only actually need these imports when running the mypy checks - pass - - __all__ = ("EncryptedTable",) diff --git a/src/dynamodb_encryption_sdk/internal/crypto/authentication.py b/src/dynamodb_encryption_sdk/internal/crypto/authentication.py index d5247688..622e03b5 100644 --- a/src/dynamodb_encryption_sdk/internal/crypto/authentication.py +++ b/src/dynamodb_encryption_sdk/internal/crypto/authentication.py @@ -16,25 +16,19 @@ No guarantee is provided on the modules and APIs within this namespace staying consistent. Directly reference at your own risk. """ +from typing import Text + from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives import hashes from dynamodb_encryption_sdk.delegated_keys import DelegatedKey # noqa pylint: disable=unused-import from dynamodb_encryption_sdk.encrypted import CryptoConfig # noqa pylint: disable=unused-import from dynamodb_encryption_sdk.identifiers import CryptoAction +from dynamodb_encryption_sdk.internal import dynamodb_types from dynamodb_encryption_sdk.internal.formatting.serialize.attribute import serialize_attribute from dynamodb_encryption_sdk.internal.identifiers import TEXT_ENCODING, SignatureValues, Tag from dynamodb_encryption_sdk.structures import AttributeActions # noqa pylint: disable=unused-import -try: # Python 3.5.0 and 3.5.1 have incompatible typing modules - from typing import Text # noqa pylint: disable=unused-import - - from dynamodb_encryption_sdk.internal import dynamodb_types # noqa pylint: disable=unused-import -except ImportError: # pragma: no cover - # We only actually need these imports when running the mypy checks - pass - - __all__ = ("sign_item", "verify_item_signature") diff --git a/src/dynamodb_encryption_sdk/internal/crypto/encryption.py b/src/dynamodb_encryption_sdk/internal/crypto/encryption.py index 3737d520..e8b72749 100644 --- a/src/dynamodb_encryption_sdk/internal/crypto/encryption.py +++ b/src/dynamodb_encryption_sdk/internal/crypto/encryption.py @@ -16,15 +16,11 @@ No guarantee is provided on the modules and APIs within this namespace staying consistent. Directly reference at your own risk. """ -try: # Python 3.5.0 and 3.5.1 have incompatible typing modules - from typing import Text # noqa pylint: disable=unused-import - from dynamodb_encryption_sdk.internal import dynamodb_types # noqa pylint: disable=unused-import -except ImportError: # pragma: no cover - # We only actually need these imports when running the mypy checks - pass +from typing import Text from dynamodb_encryption_sdk.delegated_keys import DelegatedKey # noqa pylint: disable=unused-import +from dynamodb_encryption_sdk.internal import dynamodb_types from dynamodb_encryption_sdk.internal.formatting.deserialize.attribute import deserialize_attribute from dynamodb_encryption_sdk.internal.formatting.serialize.attribute import serialize_attribute from dynamodb_encryption_sdk.internal.identifiers import Tag diff --git a/src/dynamodb_encryption_sdk/internal/crypto/jce_bridge/authentication.py b/src/dynamodb_encryption_sdk/internal/crypto/jce_bridge/authentication.py index b2244ac7..0d1b08e8 100644 --- a/src/dynamodb_encryption_sdk/internal/crypto/jce_bridge/authentication.py +++ b/src/dynamodb_encryption_sdk/internal/crypto/jce_bridge/authentication.py @@ -18,6 +18,7 @@ """ import abc import logging +from typing import Any, Callable, Text import attr import six @@ -32,12 +33,6 @@ from .primitives import load_rsa_key -try: # Python 3.5.0 and 3.5.1 have incompatible typing modules - from typing import Any, Callable, Text # noqa pylint: disable=unused-import -except ImportError: # pragma: no cover - # We only actually need these imports when running the mypy checks - pass - __all__ = ("JavaAuthenticator", "JavaMac", "JavaSignature", "JAVA_AUTHENTICATOR") _LOGGER = logging.getLogger(LOGGER_NAME) diff --git a/src/dynamodb_encryption_sdk/internal/crypto/jce_bridge/primitives.py b/src/dynamodb_encryption_sdk/internal/crypto/jce_bridge/primitives.py index 564bed80..2d6f667c 100644 --- a/src/dynamodb_encryption_sdk/internal/crypto/jce_bridge/primitives.py +++ b/src/dynamodb_encryption_sdk/internal/crypto/jce_bridge/primitives.py @@ -19,6 +19,7 @@ import abc import logging import os +from typing import Any, Callable, Text import attr import six @@ -38,13 +39,6 @@ from dynamodb_encryption_sdk.internal.identifiers import MinimumKeySizes from dynamodb_encryption_sdk.internal.validators import callable_validator -try: # Python 3.5.0 and 3.5.1 have incompatible typing modules - from typing import Any, Callable, Text # noqa pylint: disable=unused-import -except ImportError: # pragma: no cover - # We only actually need these imports when running the mypy checks - pass - - __all__ = ( "JavaPadding", "SimplePadding", diff --git a/src/dynamodb_encryption_sdk/internal/dynamodb_types.py b/src/dynamodb_encryption_sdk/internal/dynamodb_types.py index 0509a59b..01b4becb 100644 --- a/src/dynamodb_encryption_sdk/internal/dynamodb_types.py +++ b/src/dynamodb_encryption_sdk/internal/dynamodb_types.py @@ -5,24 +5,20 @@ namespace staying consistent. Directly reference at your own risk. """ # constant naming for types so pylint: disable=invalid-name -try: # Python 3.5.0 and 3.5.1 have incompatible typing modules - from typing import Any, AnyStr, ByteString, Dict, List, Text +from typing import Any, AnyStr, ByteString, Dict, List, Text - # https://github.com/aws/aws-dynamodb-encryption-python/issues/66 - ATTRIBUTE = Dict[Text, Any] # narrow this down - ITEM = Dict[Text, ATTRIBUTE] - RAW_ATTRIBUTE = ITEM - NULL = bool # DynamoDB TypeSerializer converts none to {'NULL': True} - BOOLEAN = bool - # https://github.com/aws/aws-dynamodb-encryption-python/issues/66 - NUMBER = int # This misses long on Python 2...figure out something for this - # https://github.com/aws/aws-dynamodb-encryption-python/issues/66 - STRING = AnyStr # can be unicode but should not be bytes - BINARY = ByteString - BINARY_ATTRIBUTE = Dict[Text, BINARY] - SET = List # DynamoDB TypeSerializer converts sets into lists - MAP = RAW_ATTRIBUTE - LIST = List[RAW_ATTRIBUTE] -except ImportError: # pragma: no cover - # We only actually need these imports when running the mypy checks - pass +# https://github.com/aws/aws-dynamodb-encryption-python/issues/66 +ATTRIBUTE = Dict[Text, Any] # narrow this down +ITEM = Dict[Text, ATTRIBUTE] +RAW_ATTRIBUTE = ITEM +NULL = bool # DynamoDB TypeSerializer converts none to {'NULL': True} +BOOLEAN = bool +# https://github.com/aws/aws-dynamodb-encryption-python/issues/66 +NUMBER = int # This misses long on Python 2...figure out something for this +# https://github.com/aws/aws-dynamodb-encryption-python/issues/66 +STRING = AnyStr # can be unicode but should not be bytes +BINARY = ByteString +BINARY_ATTRIBUTE = Dict[Text, BINARY] +SET = List # DynamoDB TypeSerializer converts sets into lists +MAP = RAW_ATTRIBUTE +LIST = List[RAW_ATTRIBUTE] diff --git a/src/dynamodb_encryption_sdk/internal/formatting/deserialize/attribute.py b/src/dynamodb_encryption_sdk/internal/formatting/deserialize/attribute.py index 41058916..164ad303 100644 --- a/src/dynamodb_encryption_sdk/internal/formatting/deserialize/attribute.py +++ b/src/dynamodb_encryption_sdk/internal/formatting/deserialize/attribute.py @@ -21,24 +21,17 @@ import logging import struct from decimal import Decimal +from typing import Callable, Dict, List, Text, Union from boto3.dynamodb.types import Binary from dynamodb_encryption_sdk.exceptions import DeserializationError from dynamodb_encryption_sdk.identifiers import LOGGER_NAME +from dynamodb_encryption_sdk.internal import dynamodb_types from dynamodb_encryption_sdk.internal.formatting.deserialize import decode_byte, decode_length, decode_tag, decode_value from dynamodb_encryption_sdk.internal.identifiers import TEXT_ENCODING, Tag, TagValues from dynamodb_encryption_sdk.internal.str_ops import to_str -try: # Python 3.5.0 and 3.5.1 have incompatible typing modules - from typing import Callable, Dict, List, Text, Union # noqa pylint: disable=unused-import - - from dynamodb_encryption_sdk.internal import dynamodb_types # noqa pylint: disable=unused-import,ungrouped-imports -except ImportError: # pragma: no cover - # We only actually need these imports when running the mypy checks - pass - - __all__ = ("deserialize_attribute",) _LOGGER = logging.getLogger(LOGGER_NAME) diff --git a/src/dynamodb_encryption_sdk/internal/formatting/material_description.py b/src/dynamodb_encryption_sdk/internal/formatting/material_description.py index 1f6af4a2..4657a34c 100644 --- a/src/dynamodb_encryption_sdk/internal/formatting/material_description.py +++ b/src/dynamodb_encryption_sdk/internal/formatting/material_description.py @@ -19,24 +19,17 @@ import io import logging import struct +from typing import Dict, Text from dynamodb_encryption_sdk.exceptions import InvalidMaterialDescriptionError, InvalidMaterialDescriptionVersionError from dynamodb_encryption_sdk.identifiers import LOGGER_NAME +from dynamodb_encryption_sdk.internal import dynamodb_types from dynamodb_encryption_sdk.internal.identifiers import Tag from dynamodb_encryption_sdk.internal.str_ops import to_bytes, to_str from .deserialize import decode_value, unpack_value from .serialize import encode_value -try: # Python 3.5.0 and 3.5.1 have incompatible typing modules - from typing import Dict, Text # noqa pylint: disable=unused-import - - from dynamodb_encryption_sdk.internal import dynamodb_types # noqa pylint: disable=unused-import -except ImportError: # pragma: no cover - # We only actually need these imports when running the mypy checks - pass - - __all__ = ("serialize", "deserialize") _LOGGER = logging.getLogger(LOGGER_NAME) _MATERIAL_DESCRIPTION_VERSION = b"\00" * 4 diff --git a/src/dynamodb_encryption_sdk/internal/formatting/serialize/__init__.py b/src/dynamodb_encryption_sdk/internal/formatting/serialize/__init__.py index 1c7f7ee2..07caf22b 100644 --- a/src/dynamodb_encryption_sdk/internal/formatting/serialize/__init__.py +++ b/src/dynamodb_encryption_sdk/internal/formatting/serialize/__init__.py @@ -17,12 +17,7 @@ namespace staying consistent. Directly reference at your own risk. """ import struct - -try: # Python 3.5.0 and 3.5.1 have incompatible typing modules - from typing import Sized # noqa pylint: disable=unused-import -except ImportError: # pragma: no cover - # We only actually need these imports when running the mypy checks - pass +from typing import Sized __all__ = ("encode_length", "encode_value") diff --git a/src/dynamodb_encryption_sdk/internal/formatting/serialize/attribute.py b/src/dynamodb_encryption_sdk/internal/formatting/serialize/attribute.py index 1ca416a1..49a0097c 100644 --- a/src/dynamodb_encryption_sdk/internal/formatting/serialize/attribute.py +++ b/src/dynamodb_encryption_sdk/internal/formatting/serialize/attribute.py @@ -18,24 +18,17 @@ """ import io import logging +from typing import Callable from boto3.dynamodb.types import DYNAMODB_CONTEXT, Binary from dynamodb_encryption_sdk.exceptions import SerializationError from dynamodb_encryption_sdk.identifiers import LOGGER_NAME +from dynamodb_encryption_sdk.internal import dynamodb_types from dynamodb_encryption_sdk.internal.formatting.serialize import encode_length, encode_value from dynamodb_encryption_sdk.internal.identifiers import Tag, TagValues from dynamodb_encryption_sdk.internal.str_ops import to_bytes -try: # Python 3.5.0 and 3.5.1 have incompatible typing modules - from typing import Callable # noqa pylint: disable=unused-import - - from dynamodb_encryption_sdk.internal import dynamodb_types # noqa pylint: disable=unused-import,ungrouped-imports -except ImportError: # pragma: no cover - # We only actually need these imports when running the mypy checks - pass - - __all__ = ("serialize_attribute",) _LOGGER = logging.getLogger(LOGGER_NAME) _RESERVED = b"\x00" diff --git a/src/dynamodb_encryption_sdk/internal/identifiers.py b/src/dynamodb_encryption_sdk/internal/identifiers.py index 94d7bd41..facc1266 100644 --- a/src/dynamodb_encryption_sdk/internal/identifiers.py +++ b/src/dynamodb_encryption_sdk/internal/identifiers.py @@ -17,12 +17,7 @@ namespace staying consistent. Directly reference at your own risk. """ from enum import Enum - -try: # Python 3.5.0 and 3.5.1 have incompatible typing modules - from typing import Optional, Text # noqa pylint: disable=unused-import -except ImportError: # pragma: no cover - # We only actually need these imports when running the mypy checks - pass +from typing import Optional, Text __all__ = ( "ReservedAttributes", diff --git a/src/dynamodb_encryption_sdk/internal/utils.py b/src/dynamodb_encryption_sdk/internal/utils.py index 27fe6b0a..cdb6266c 100644 --- a/src/dynamodb_encryption_sdk/internal/utils.py +++ b/src/dynamodb_encryption_sdk/internal/utils.py @@ -18,6 +18,7 @@ """ import copy from functools import partial +from typing import Any, Callable, Dict, Iterable, Text import attr import botocore.client @@ -28,12 +29,6 @@ from dynamodb_encryption_sdk.structures import CryptoAction, EncryptionContext, TableInfo from dynamodb_encryption_sdk.transform import dict_to_ddb -try: # Python 3.5.0 and 3.5.1 have incompatible typing modules - from typing import Any, Bool, Callable, Dict, Iterable, Text # noqa pylint: disable=unused-import -except ImportError: # pragma: no cover - # We only actually need these imports when running the mypy checks - pass - __all__ = ( "TableInfoCache", "crypto_config_from_kwargs", @@ -366,7 +361,7 @@ def _process_batch_write_response(request, response, table_crypto_config): def _item_keys_match(crypto_config, item1, item2): - # type: (CryptoConfig, Dict, Dict) -> Bool + # type: (CryptoConfig, Dict, Dict) -> bool """Determines whether the values in the primary and sort keys (if they exist) are the same :param CryptoConfig crypto_config: CryptoConfig used in encrypting the given items @@ -387,7 +382,7 @@ def _item_keys_match(crypto_config, item1, item2): def _item_attributes_match(crypto_config, plaintext_item, encrypted_item): - # type: (CryptoConfig, Dict, Dict) -> Bool + # type: (CryptoConfig, Dict, Dict) -> bool """Determines whether the unencrypted values in the plaintext items attributes are the same as those in the encrypted item. Essentially this uses brute force to cover when we don't know the primary and sort index attribute names, since they can't be encrypted. diff --git a/src/dynamodb_encryption_sdk/material_providers/aws_kms.py b/src/dynamodb_encryption_sdk/material_providers/aws_kms.py index ea7a55f2..73212999 100644 --- a/src/dynamodb_encryption_sdk/material_providers/aws_kms.py +++ b/src/dynamodb_encryption_sdk/material_providers/aws_kms.py @@ -16,6 +16,7 @@ import base64 import logging from enum import Enum +from typing import Dict, Optional, Text, Tuple import attr import boto3 @@ -28,6 +29,7 @@ from dynamodb_encryption_sdk.delegated_keys.jce import JceNameLocalDelegatedKey from dynamodb_encryption_sdk.exceptions import UnknownRegionError, UnwrappingError, WrappingError from dynamodb_encryption_sdk.identifiers import LOGGER_NAME, USER_AGENT_SUFFIX, EncryptionKeyType, KeyEncodingType +from dynamodb_encryption_sdk.internal import dynamodb_types from dynamodb_encryption_sdk.internal.identifiers import TEXT_ENCODING, MaterialDescriptionKeys from dynamodb_encryption_sdk.internal.str_ops import to_bytes, to_str from dynamodb_encryption_sdk.internal.validators import dictionary_validator, iterable_validator @@ -36,15 +38,6 @@ from . import CryptographicMaterialsProvider -try: # Python 3.5.0 and 3.5.1 have incompatible typing modules - from typing import Dict, Optional, Text, Tuple # noqa pylint: disable=unused-import - - from dynamodb_encryption_sdk.internal import dynamodb_types # noqa pylint: disable=unused-import -except ImportError: # pragma: no cover - # We only actually need these imports when running the mypy checks - pass - - __all__ = ("AwsKmsCryptographicMaterialsProvider",) _LOGGER = logging.getLogger(LOGGER_NAME) diff --git a/src/dynamodb_encryption_sdk/material_providers/most_recent.py b/src/dynamodb_encryption_sdk/material_providers/most_recent.py index 1606f6c0..8a003f17 100644 --- a/src/dynamodb_encryption_sdk/material_providers/most_recent.py +++ b/src/dynamodb_encryption_sdk/material_providers/most_recent.py @@ -16,6 +16,7 @@ from collections import OrderedDict from enum import Enum from threading import Lock, RLock +from typing import Any, Text import attr import six @@ -28,13 +29,6 @@ from . import CryptographicMaterialsProvider from .store import ProviderStore -try: # Python 3.5.0 and 3.5.1 have incompatible typing modules - from typing import Any, Text # noqa pylint: disable=unused-import -except ImportError: # pragma: no cover - # We only actually need these imports when running the mypy checks - pass - - __all__ = ("CachingMostRecentProvider",) _LOGGER = logging.getLogger(LOGGER_NAME) #: Grace period during which we will return the latest local materials. This allows multiple diff --git a/src/dynamodb_encryption_sdk/material_providers/static.py b/src/dynamodb_encryption_sdk/material_providers/static.py index 966002cb..77af8478 100644 --- a/src/dynamodb_encryption_sdk/material_providers/static.py +++ b/src/dynamodb_encryption_sdk/material_providers/static.py @@ -11,6 +11,8 @@ # ANY KIND, either express or implied. See the License for the specific # language governing permissions and limitations under the License. """Cryptographic materials provider for use with pre-configured encryption and decryption materials.""" +from typing import Optional + import attr from dynamodb_encryption_sdk.materials import CryptographicMaterials # noqa pylint: disable=unused-import @@ -19,13 +21,6 @@ from . import CryptographicMaterialsProvider -try: # Python 3.5.0 and 3.5.1 have incompatible typing modules - from typing import Optional # noqa pylint: disable=unused-import -except ImportError: # pragma: no cover - # We only actually need these imports when running the mypy checks - pass - - __all__ = ("StaticCryptographicMaterialsProvider",) diff --git a/src/dynamodb_encryption_sdk/material_providers/store/__init__.py b/src/dynamodb_encryption_sdk/material_providers/store/__init__.py index e03b57b9..1948c388 100644 --- a/src/dynamodb_encryption_sdk/material_providers/store/__init__.py +++ b/src/dynamodb_encryption_sdk/material_providers/store/__init__.py @@ -12,6 +12,7 @@ # language governing permissions and limitations under the License. """Cryptographic materials provider stores.""" import abc +from typing import Optional, Text import six @@ -20,13 +21,6 @@ CryptographicMaterialsProvider, ) -try: # Python 3.5.0 and 3.5.1 have incompatible typing modules - from typing import Dict, Optional, Text # noqa pylint: disable=unused-import -except ImportError: # pragma: no cover - # We only actually need these imports when running the mypy checks - pass - - __all__ = ("ProviderStore",) diff --git a/src/dynamodb_encryption_sdk/material_providers/store/meta.py b/src/dynamodb_encryption_sdk/material_providers/store/meta.py index 46d7410f..da545ba4 100644 --- a/src/dynamodb_encryption_sdk/material_providers/store/meta.py +++ b/src/dynamodb_encryption_sdk/material_providers/store/meta.py @@ -13,6 +13,7 @@ """Meta cryptographic provider store.""" import logging from enum import Enum +from typing import Dict, Optional, Text, Tuple import attr import botocore @@ -29,13 +30,6 @@ from . import ProviderStore -try: # Python 3.5.0 and 3.5.1 have incompatible typing modules - from typing import Dict, Optional, Text, Tuple # noqa pylint: disable=unused-import -except ImportError: # pragma: no cover - # We only actually need these imports when running the mypy checks - pass - - __all__ = ("MetaStore",) _LOGGER = logging.getLogger(LOGGER_NAME) diff --git a/src/dynamodb_encryption_sdk/material_providers/wrapped.py b/src/dynamodb_encryption_sdk/material_providers/wrapped.py index 13f6a346..416156c7 100644 --- a/src/dynamodb_encryption_sdk/material_providers/wrapped.py +++ b/src/dynamodb_encryption_sdk/material_providers/wrapped.py @@ -11,6 +11,8 @@ # ANY KIND, either express or implied. See the License for the specific # language governing permissions and limitations under the License. """Cryptographic materials provider to use ephemeral content encryption keys wrapped by delegated keys.""" +from typing import Dict, Optional, Text + import attr import six @@ -22,19 +24,6 @@ from . import CryptographicMaterialsProvider -try: # Python 3.5.0 and 3.5.1 have incompatible typing modules - from typing import Dict, Optional, Text # noqa pylint: disable=unused-import -except ImportError: # pragma: no cover - # We only actually need these imports when running the mypy checks - pass - -try: # Python 3.5.0 and 3.5.1 have incompatible typing modules - from typing import Optional # noqa pylint: disable=unused-import -except ImportError: # pragma: no cover - # We only actually need these imports when running the mypy checks - pass - - __all__ = ("WrappedCryptographicMaterialsProvider",) diff --git a/src/dynamodb_encryption_sdk/materials/__init__.py b/src/dynamodb_encryption_sdk/materials/__init__.py index 09c4a470..3b9788d0 100644 --- a/src/dynamodb_encryption_sdk/materials/__init__.py +++ b/src/dynamodb_encryption_sdk/materials/__init__.py @@ -12,20 +12,12 @@ # language governing permissions and limitations under the License. """Cryptographic materials are containers that provide delegated keys for cryptographic operations.""" import abc +from typing import Dict, Text import six from dynamodb_encryption_sdk.delegated_keys import DelegatedKey # noqa pylint: disable=unused-import -try: # Python 3.5.0 and 3.5.1 have incompatible typing modules - from typing import Dict, Text # noqa pylint: disable=unused-import - - from mypy_extensions import NoReturn # noqa pylint: disable=unused-import -except ImportError: # pragma: no cover - # We only actually need these imports when running the mypy checks - pass - - __all__ = ("CryptographicMaterials", "EncryptionMaterials", "DecryptionMaterials") @@ -89,7 +81,6 @@ class EncryptionMaterials(CryptographicMaterials): @property def decryption_key(self): - # type: () -> NoReturn """Encryption materials do not provide decryption keys. :raises NotImplementedError: because encryption materials do not contain decryption keys @@ -98,7 +89,6 @@ def decryption_key(self): @property def verification_key(self): - # type: () -> NoReturn """Encryption materials do not provide verification keys. :raises NotImplementedError: because encryption materials do not contain verification keys @@ -111,7 +101,6 @@ class DecryptionMaterials(CryptographicMaterials): @property def encryption_key(self): - # type: () -> NoReturn """Decryption materials do not provide encryption keys. :raises NotImplementedError: because decryption materials do not contain encryption keys @@ -120,7 +109,6 @@ def encryption_key(self): @property def signing_key(self): - # type: () -> NoReturn """Decryption materials do not provide signing keys. :raises NotImplementedError: because decryption materials do not contain signing keys diff --git a/src/dynamodb_encryption_sdk/materials/raw.py b/src/dynamodb_encryption_sdk/materials/raw.py index 7c2e85e4..d2587339 100644 --- a/src/dynamodb_encryption_sdk/materials/raw.py +++ b/src/dynamodb_encryption_sdk/materials/raw.py @@ -23,6 +23,7 @@ that you use wrapped cryptographic materials instead. """ import copy +from typing import Dict, Optional, Text import attr import six @@ -31,13 +32,6 @@ from dynamodb_encryption_sdk.internal.validators import dictionary_validator from dynamodb_encryption_sdk.materials import DecryptionMaterials, EncryptionMaterials -try: # Python 3.5.0 and 3.5.1 have incompatible typing modules - from typing import Dict, Optional, Text # noqa pylint: disable=unused-import -except ImportError: # pragma: no cover - # We only actually need these imports when running the mypy checks - pass - - __all__ = ("RawEncryptionMaterials", "RawDecryptionMaterials") diff --git a/src/dynamodb_encryption_sdk/materials/wrapped.py b/src/dynamodb_encryption_sdk/materials/wrapped.py index f85924ea..74d2784c 100644 --- a/src/dynamodb_encryption_sdk/materials/wrapped.py +++ b/src/dynamodb_encryption_sdk/materials/wrapped.py @@ -13,6 +13,7 @@ """Cryptographic materials to use ephemeral content encryption keys wrapped by delegated keys.""" import base64 import copy +from typing import Dict, Optional, Text import attr import six @@ -25,13 +26,6 @@ from dynamodb_encryption_sdk.internal.validators import dictionary_validator from dynamodb_encryption_sdk.materials import CryptographicMaterials -try: # Python 3.5.0 and 3.5.1 have incompatible typing modules - from typing import Dict, Optional, Text # noqa pylint: disable=unused-import -except ImportError: # pragma: no cover - # We only actually need these imports when running the mypy checks - pass - - __all__ = ("WrappedCryptographicMaterials",) _DEFAULT_CONTENT_ENCRYPTION_ALGORITHM = "AES/256" _WRAPPING_TRANSFORMATION = {"AES": "AESWrap", "RSA": "RSA/ECB/OAEPWithSHA-256AndMGF1Padding"} diff --git a/src/dynamodb_encryption_sdk/structures.py b/src/dynamodb_encryption_sdk/structures.py index 522f1d14..16976b98 100644 --- a/src/dynamodb_encryption_sdk/structures.py +++ b/src/dynamodb_encryption_sdk/structures.py @@ -12,6 +12,7 @@ # language governing permissions and limitations under the License. """Common structures used by the DynamoDB Encryption Client.""" import copy +from typing import Dict, Iterable, List, Optional, Set, Text import attr import six @@ -22,13 +23,6 @@ from .identifiers import CryptoAction -try: # Python 3.5.0 and 3.5.1 have incompatible typing modules - from typing import Dict, Iterable, List, Optional, Set, Text # noqa pylint: disable=unused-import -except ImportError: # pragma: no cover - # We only actually need these imports when running the mypy checks - pass - - __all__ = ("EncryptionContext", "AttributeActions", "TableIndex", "TableInfo") diff --git a/src/dynamodb_encryption_sdk/transform.py b/src/dynamodb_encryption_sdk/transform.py index 347024d3..d79b8504 100644 --- a/src/dynamodb_encryption_sdk/transform.py +++ b/src/dynamodb_encryption_sdk/transform.py @@ -11,11 +11,7 @@ # ANY KIND, either express or implied. See the License for the specific # language governing permissions and limitations under the License. """Helper tools for translating between native and DynamoDB items.""" -try: # Python 3.5.0 and 3.5.1 have incompatible typing modules - from typing import Any, Dict # noqa pylint: disable=unused-import -except ImportError: # pragma: no cover - # We only actually need these imports when running the mypy checks - pass +from typing import Any, Dict from boto3.dynamodb.types import TypeDeserializer, TypeSerializer