Skip to content

Commit b4e40e3

Browse files
removed-typehints-and-imports
1 parent 30367f3 commit b4e40e3

28 files changed

+58
-173
lines changed

src/dynamodb_encryption_sdk/delegated_keys/__init__.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@
1717

1818
from dynamodb_encryption_sdk.identifiers import EncryptionKeyType # noqa pylint: disable=unused-import
1919

20-
try: # Python 3.5.0 and 3.5.1 have incompatible typing modules
21-
from typing import Dict, Optional, Text # noqa pylint: disable=unused-import
22-
except ImportError: # pragma: no cover
23-
# We only actually need these imports when running the mypy checks
24-
pass
20+
from typing import Dict, Optional, Text
2521

2622

2723
__all__ = ("DelegatedKey",)

src/dynamodb_encryption_sdk/delegated_keys/jce.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,7 @@
2828

2929
from . import DelegatedKey
3030

31-
try: # Python 3.5.0 and 3.5.1 have incompatible typing modules
32-
from typing import Dict, Optional, Text # noqa pylint: disable=unused-import
33-
except ImportError: # pragma: no cover
34-
# We only actually need these imports when running the mypy checks
35-
pass
31+
from typing import Dict, Optional, Text
3632

3733

3834
__all__ = ("JceNameLocalDelegatedKey",)

src/dynamodb_encryption_sdk/encrypted/__init__.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,7 @@
2121
from dynamodb_encryption_sdk.materials import CryptographicMaterials # noqa pylint: disable=unused-import
2222
from dynamodb_encryption_sdk.structures import AttributeActions, EncryptionContext
2323

24-
try: # Python 3.5.0 and 3.5.1 have incompatible typing modules
25-
from typing import Dict # noqa pylint: disable=unused-import
26-
except ImportError: # pragma: no cover
27-
# We only actually need these imports when running the mypy checks
28-
pass
24+
from typing import Dict
2925

3026

3127
__all__ = ("CryptoConfig",)

src/dynamodb_encryption_sdk/encrypted/client.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,7 @@
3434

3535
from .item import decrypt_dynamodb_item, decrypt_python_item, encrypt_dynamodb_item, encrypt_python_item
3636

37-
try: # Python 3.5.0 and 3.5.1 have incompatible typing modules
38-
from typing import Any, Callable, Dict, Iterator, Optional # noqa pylint: disable=unused-import
39-
except ImportError: # pragma: no cover
40-
# We only actually need these imports when running the mypy checks
41-
pass
37+
from typing import Any, Callable, Dict, Iterator, Optional
4238

4339

4440
__all__ = ("EncryptedClient", "EncryptedPaginator")

src/dynamodb_encryption_sdk/encrypted/item.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@
1111
# ANY KIND, either express or implied. See the License for the specific
1212
# language governing permissions and limitations under the License.
1313
"""Top-level functions for encrypting and decrypting DynamoDB items."""
14-
try: # Python 3.5.0 and 3.5.1 have incompatible typing modules
15-
from dynamodb_encryption_sdk.internal import dynamodb_types # noqa pylint: disable=unused-import
16-
except ImportError: # pragma: no cover
17-
# We only actually need these imports when running the mypy checks
18-
pass
14+
from dynamodb_encryption_sdk.internal import dynamodb_types
1915

2016
from dynamodb_encryption_sdk.exceptions import DecryptionError, EncryptionError
2117
from dynamodb_encryption_sdk.identifiers import CryptoAction
@@ -34,6 +30,7 @@
3430

3531
from . import CryptoConfig # noqa pylint: disable=unused-import
3632

33+
3734
__all__ = ("encrypt_dynamodb_item", "encrypt_python_item", "decrypt_dynamodb_item", "decrypt_python_item")
3835

3936

src/dynamodb_encryption_sdk/encrypted/resource.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,7 @@
2929
from .item import decrypt_python_item, encrypt_python_item
3030
from .table import EncryptedTable
3131

32-
try: # Python 3.5.0 and 3.5.1 have incompatible typing modules
33-
from typing import Optional # noqa pylint: disable=unused-import
34-
except ImportError: # pragma: no cover
35-
# We only actually need these imports when running the mypy checks
36-
pass
32+
from typing import Optional
3733

3834

3935
__all__ = ("EncryptedResource", "EncryptedTablesCollectionManager")

src/dynamodb_encryption_sdk/encrypted/table.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,7 @@
3030
from .client import EncryptedClient
3131
from .item import decrypt_python_item, encrypt_python_item
3232

33-
try: # Python 3.5.0 and 3.5.1 have incompatible typing modules
34-
from typing import Optional # noqa pylint: disable=unused-import
35-
except ImportError: # pragma: no cover
36-
# We only actually need these imports when running the mypy checks
37-
pass
33+
from typing import Optional
3834

3935

4036
__all__ = ("EncryptedTable",)

src/dynamodb_encryption_sdk/internal/crypto/authentication.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,9 @@
2626
from dynamodb_encryption_sdk.internal.identifiers import TEXT_ENCODING, SignatureValues, Tag
2727
from dynamodb_encryption_sdk.structures import AttributeActions # noqa pylint: disable=unused-import
2828

29-
try: # Python 3.5.0 and 3.5.1 have incompatible typing modules
30-
from typing import Text # noqa pylint: disable=unused-import
29+
from typing import Text
3130

32-
from dynamodb_encryption_sdk.internal import dynamodb_types # noqa pylint: disable=unused-import
33-
except ImportError: # pragma: no cover
34-
# We only actually need these imports when running the mypy checks
35-
pass
31+
from dynamodb_encryption_sdk.internal import dynamodb_types
3632

3733

3834
__all__ = ("sign_item", "verify_item_signature")

src/dynamodb_encryption_sdk/internal/crypto/encryption.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,17 @@
1616
No guarantee is provided on the modules and APIs within this
1717
namespace staying consistent. Directly reference at your own risk.
1818
"""
19-
try: # Python 3.5.0 and 3.5.1 have incompatible typing modules
20-
from typing import Text # noqa pylint: disable=unused-import
2119

22-
from dynamodb_encryption_sdk.internal import dynamodb_types # noqa pylint: disable=unused-import
23-
except ImportError: # pragma: no cover
24-
# We only actually need these imports when running the mypy checks
25-
pass
20+
from typing import Text
21+
22+
from dynamodb_encryption_sdk.internal import dynamodb_types
2623

2724
from dynamodb_encryption_sdk.delegated_keys import DelegatedKey # noqa pylint: disable=unused-import
2825
from dynamodb_encryption_sdk.internal.formatting.deserialize.attribute import deserialize_attribute
2926
from dynamodb_encryption_sdk.internal.formatting.serialize.attribute import serialize_attribute
3027
from dynamodb_encryption_sdk.internal.identifiers import Tag
3128

29+
3230
__all__ = ("encrypt_attribute", "decrypt_attribute")
3331

3432

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,8 @@
3232

3333
from .primitives import load_rsa_key
3434

35-
try: # Python 3.5.0 and 3.5.1 have incompatible typing modules
36-
from typing import Any, Callable, Text # noqa pylint: disable=unused-import
37-
except ImportError: # pragma: no cover
38-
# We only actually need these imports when running the mypy checks
39-
pass
35+
from typing import Any, Callable, Text
36+
4037

4138
__all__ = ("JavaAuthenticator", "JavaMac", "JavaSignature", "JAVA_AUTHENTICATOR")
4239
_LOGGER = logging.getLogger(LOGGER_NAME)

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,7 @@
3838
from dynamodb_encryption_sdk.internal.identifiers import MinimumKeySizes
3939
from dynamodb_encryption_sdk.internal.validators import callable_validator
4040

41-
try: # Python 3.5.0 and 3.5.1 have incompatible typing modules
42-
from typing import Any, Callable, Text # noqa pylint: disable=unused-import
43-
except ImportError: # pragma: no cover
44-
# We only actually need these imports when running the mypy checks
45-
pass
41+
from typing import Any, Callable, Text
4642

4743

4844
__all__ = (

src/dynamodb_encryption_sdk/internal/dynamodb_types.py

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,20 @@
55
namespace staying consistent. Directly reference at your own risk.
66
"""
77
# constant naming for types so pylint: disable=invalid-name
8-
try: # Python 3.5.0 and 3.5.1 have incompatible typing modules
9-
from typing import Any, AnyStr, ByteString, Dict, List, Text
8+
from typing import Any, AnyStr, ByteString, Dict, List, Text
109

11-
# https://github.com/aws/aws-dynamodb-encryption-python/issues/66
12-
ATTRIBUTE = Dict[Text, Any] # narrow this down
13-
ITEM = Dict[Text, ATTRIBUTE]
14-
RAW_ATTRIBUTE = ITEM
15-
NULL = bool # DynamoDB TypeSerializer converts none to {'NULL': True}
16-
BOOLEAN = bool
17-
# https://github.com/aws/aws-dynamodb-encryption-python/issues/66
18-
NUMBER = int # This misses long on Python 2...figure out something for this
19-
# https://github.com/aws/aws-dynamodb-encryption-python/issues/66
20-
STRING = AnyStr # can be unicode but should not be bytes
21-
BINARY = ByteString
22-
BINARY_ATTRIBUTE = Dict[Text, BINARY]
23-
SET = List # DynamoDB TypeSerializer converts sets into lists
24-
MAP = RAW_ATTRIBUTE
25-
LIST = List[RAW_ATTRIBUTE]
26-
except ImportError: # pragma: no cover
27-
# We only actually need these imports when running the mypy checks
28-
pass
10+
# https://github.com/aws/aws-dynamodb-encryption-python/issues/66
11+
ATTRIBUTE = Dict[Text, Any] # narrow this down
12+
ITEM = Dict[Text, ATTRIBUTE]
13+
RAW_ATTRIBUTE = ITEM
14+
NULL = bool # DynamoDB TypeSerializer converts none to {'NULL': True}
15+
BOOLEAN = bool
16+
# https://github.com/aws/aws-dynamodb-encryption-python/issues/66
17+
NUMBER = int # This misses long on Python 2...figure out something for this
18+
# https://github.com/aws/aws-dynamodb-encryption-python/issues/66
19+
STRING = AnyStr # can be unicode but should not be bytes
20+
BINARY = ByteString
21+
BINARY_ATTRIBUTE = Dict[Text, BINARY]
22+
SET = List # DynamoDB TypeSerializer converts sets into lists
23+
MAP = RAW_ATTRIBUTE
24+
LIST = List[RAW_ATTRIBUTE]

src/dynamodb_encryption_sdk/internal/formatting/deserialize/attribute.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,9 @@
3030
from dynamodb_encryption_sdk.internal.identifiers import TEXT_ENCODING, Tag, TagValues
3131
from dynamodb_encryption_sdk.internal.str_ops import to_str
3232

33-
try: # Python 3.5.0 and 3.5.1 have incompatible typing modules
34-
from typing import Callable, Dict, List, Text, Union # noqa pylint: disable=unused-import
33+
from typing import Callable, Dict, List, Text, Union
3534

36-
from dynamodb_encryption_sdk.internal import dynamodb_types # noqa pylint: disable=unused-import,ungrouped-imports
37-
except ImportError: # pragma: no cover
38-
# We only actually need these imports when running the mypy checks
39-
pass
35+
from dynamodb_encryption_sdk.internal import dynamodb_types
4036

4137

4238
__all__ = ("deserialize_attribute",)

src/dynamodb_encryption_sdk/internal/formatting/material_description.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,8 @@
2828
from .deserialize import decode_value, unpack_value
2929
from .serialize import encode_value
3030

31-
try: # Python 3.5.0 and 3.5.1 have incompatible typing modules
32-
from typing import Dict, Text # noqa pylint: disable=unused-import
33-
34-
from dynamodb_encryption_sdk.internal import dynamodb_types # noqa pylint: disable=unused-import
35-
except ImportError: # pragma: no cover
36-
# We only actually need these imports when running the mypy checks
37-
pass
31+
from typing import Dict, Text
32+
from dynamodb_encryption_sdk.internal import dynamodb_types
3833

3934

4035
__all__ = ("serialize", "deserialize")

src/dynamodb_encryption_sdk/internal/formatting/serialize/__init__.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,8 @@
1818
"""
1919
import struct
2020

21-
try: # Python 3.5.0 and 3.5.1 have incompatible typing modules
22-
from typing import Sized # noqa pylint: disable=unused-import
23-
except ImportError: # pragma: no cover
24-
# We only actually need these imports when running the mypy checks
25-
pass
21+
from typing import Sized
22+
2623

2724
__all__ = ("encode_length", "encode_value")
2825

src/dynamodb_encryption_sdk/internal/formatting/serialize/attribute.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,9 @@
2727
from dynamodb_encryption_sdk.internal.identifiers import Tag, TagValues
2828
from dynamodb_encryption_sdk.internal.str_ops import to_bytes
2929

30-
try: # Python 3.5.0 and 3.5.1 have incompatible typing modules
31-
from typing import Callable # noqa pylint: disable=unused-import
30+
from typing import Callable
3231

33-
from dynamodb_encryption_sdk.internal import dynamodb_types # noqa pylint: disable=unused-import,ungrouped-imports
34-
except ImportError: # pragma: no cover
35-
# We only actually need these imports when running the mypy checks
36-
pass
32+
from dynamodb_encryption_sdk.internal import dynamodb_types
3733

3834

3935
__all__ = ("serialize_attribute",)

src/dynamodb_encryption_sdk/internal/identifiers.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,8 @@
1818
"""
1919
from enum import Enum
2020

21-
try: # Python 3.5.0 and 3.5.1 have incompatible typing modules
22-
from typing import Optional, Text # noqa pylint: disable=unused-import
23-
except ImportError: # pragma: no cover
24-
# We only actually need these imports when running the mypy checks
25-
pass
21+
from typing import Optional, Text
22+
2623

2724
__all__ = (
2825
"ReservedAttributes",

src/dynamodb_encryption_sdk/internal/utils.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,8 @@
2828
from dynamodb_encryption_sdk.structures import CryptoAction, EncryptionContext, TableInfo
2929
from dynamodb_encryption_sdk.transform import dict_to_ddb
3030

31-
try: # Python 3.5.0 and 3.5.1 have incompatible typing modules
32-
from typing import Any, Bool, Callable, Dict, Iterable, Text # noqa pylint: disable=unused-import
33-
except ImportError: # pragma: no cover
34-
# We only actually need these imports when running the mypy checks
35-
pass
31+
from typing import Any, Bool, Callable, Dict, Iterable, Text
32+
3633

3734
__all__ = (
3835
"TableInfoCache",

src/dynamodb_encryption_sdk/material_providers/aws_kms.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,8 @@
3636

3737
from . import CryptographicMaterialsProvider
3838

39-
try: # Python 3.5.0 and 3.5.1 have incompatible typing modules
40-
from typing import Dict, Optional, Text, Tuple # noqa pylint: disable=unused-import
41-
42-
from dynamodb_encryption_sdk.internal import dynamodb_types # noqa pylint: disable=unused-import
43-
except ImportError: # pragma: no cover
44-
# We only actually need these imports when running the mypy checks
45-
pass
39+
from typing import Dict, Optional, Text, Tuple
40+
from dynamodb_encryption_sdk.internal import dynamodb_types
4641

4742

4843
__all__ = ("AwsKmsCryptographicMaterialsProvider",)

src/dynamodb_encryption_sdk/material_providers/most_recent.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,7 @@
2828
from . import CryptographicMaterialsProvider
2929
from .store import ProviderStore
3030

31-
try: # Python 3.5.0 and 3.5.1 have incompatible typing modules
32-
from typing import Any, Text # noqa pylint: disable=unused-import
33-
except ImportError: # pragma: no cover
34-
# We only actually need these imports when running the mypy checks
35-
pass
31+
from typing import Any, Text
3632

3733

3834
__all__ = ("CachingMostRecentProvider",)

src/dynamodb_encryption_sdk/material_providers/static.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@
1919

2020
from . import CryptographicMaterialsProvider
2121

22-
try: # Python 3.5.0 and 3.5.1 have incompatible typing modules
23-
from typing import Optional # noqa pylint: disable=unused-import
24-
except ImportError: # pragma: no cover
25-
# We only actually need these imports when running the mypy checks
26-
pass
22+
from typing import Optional
2723

2824

2925
__all__ = ("StaticCryptographicMaterialsProvider",)

src/dynamodb_encryption_sdk/material_providers/store/__init__.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,7 @@
1919
from dynamodb_encryption_sdk.material_providers import ( # noqa pylint: disable=unused-import
2020
CryptographicMaterialsProvider,
2121
)
22-
23-
try: # Python 3.5.0 and 3.5.1 have incompatible typing modules
24-
from typing import Dict, Optional, Text # noqa pylint: disable=unused-import
25-
except ImportError: # pragma: no cover
26-
# We only actually need these imports when running the mypy checks
27-
pass
22+
from typing import Dict, Optional, Text
2823

2924

3025
__all__ = ("ProviderStore",)

src/dynamodb_encryption_sdk/material_providers/store/meta.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,7 @@
2929

3030
from . import ProviderStore
3131

32-
try: # Python 3.5.0 and 3.5.1 have incompatible typing modules
33-
from typing import Dict, Optional, Text, Tuple # noqa pylint: disable=unused-import
34-
except ImportError: # pragma: no cover
35-
# We only actually need these imports when running the mypy checks
36-
pass
32+
from typing import Dict, Optional, Text, Tuple
3733

3834

3935
__all__ = ("MetaStore",)

src/dynamodb_encryption_sdk/material_providers/wrapped.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,7 @@
2222

2323
from . import CryptographicMaterialsProvider
2424

25-
try: # Python 3.5.0 and 3.5.1 have incompatible typing modules
26-
from typing import Dict, Optional, Text # noqa pylint: disable=unused-import
27-
except ImportError: # pragma: no cover
28-
# We only actually need these imports when running the mypy checks
29-
pass
30-
31-
try: # Python 3.5.0 and 3.5.1 have incompatible typing modules
32-
from typing import Optional # noqa pylint: disable=unused-import
33-
except ImportError: # pragma: no cover
34-
# We only actually need these imports when running the mypy checks
35-
pass
25+
from typing import Dict, Optional, Text
3626

3727

3828
__all__ = ("WrappedCryptographicMaterialsProvider",)

0 commit comments

Comments
 (0)