Skip to content

Commit 74af899

Browse files
chore: Fix pylint checks (#360)
1 parent 55309f3 commit 74af899

File tree

16 files changed

+35
-29
lines changed

16 files changed

+35
-29
lines changed

codebuild/py38/awses_local.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ phases:
2020
python: latest
2121
build:
2222
commands:
23-
- pip install tox
23+
- pyenv install 3.8.6
24+
- pyenv local 3.8.6
25+
- pip install tox tox-pyenv
2426
- cd test_vector_handlers
2527
- tox

codebuild/py38/examples.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,7 @@ phases:
1818
python: latest
1919
build:
2020
commands:
21-
- pip install tox
21+
- pyenv install 3.8.6
22+
- pyenv local 3.8.6
23+
- pip install tox tox-pyenv
2224
- tox

codebuild/py38/integ.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,7 @@ phases:
1818
python: latest
1919
build:
2020
commands:
21-
- pip install tox
21+
- pyenv install 3.8.6
22+
- pyenv local 3.8.6
23+
- pip install tox tox-pyenv
2224
- tox

decrypt_oracle/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
def read(*args):
1212
"""Read complete file contents."""
13-
return open(os.path.join(HERE, *args)).read() # pylint: disable=consider-using-with
13+
return open(os.path.join(HERE, *args), encoding="utf-8").read() # pylint: disable=consider-using-with
1414

1515

1616
def get_version():

decrypt_oracle/test/integration/integration_test_utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def test_vectors_filename() -> Text:
100100
def all_test_vectors() -> Iterable[Any]:
101101
"""Collect and iterate through all test vectors."""
102102

103-
with open(test_vectors_filename(), "r") as vectors_file:
103+
with open(test_vectors_filename(), "r", encoding="utf-8") as vectors_file:
104104
raw_vectors = json.load(vectors_file)
105105

106106
for vector in raw_vectors:

examples/src/one_kms_cmk_streaming_data.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def encrypt_decrypt_stream(key_arn, source_plaintext_filename, botocore_session=
2525
:param botocore_session: existing botocore session instance
2626
:type botocore_session: botocore.session.Session
2727
"""
28-
kwargs = dict()
28+
kwargs = {}
2929

3030
kwargs["key_ids"] = [key_arn]
3131

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
def read(*args):
1212
"""Reads complete file contents."""
13-
return open(os.path.join(HERE, *args)).read() # pylint: disable=consider-using-with
13+
return open(os.path.join(HERE, *args), encoding="utf-8").read() # pylint: disable=consider-using-with
1414

1515

1616
def get_version():

src/aws_encryption_sdk/internal/formatting/deserialize.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ def deserialize_header(stream, max_encrypted_data_keys=None):
344344
tee_stream = TeeStream(stream, tee)
345345
(version_id,) = unpack_values(">B", tee_stream)
346346
version = _verified_version_from_id(version_id)
347-
header = dict()
347+
header = {}
348348
header["version"] = version
349349

350350
if version == SerializationVersion.V1:

test/functional/test_f_xcompat.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def _generate_test_cases(): # noqa=C901
126126
# Make no test cases if the ciphertext file is not found
127127
return []
128128

129-
with open(ciphertext_manifest_path) as f:
129+
with open(ciphertext_manifest_path, encoding="utf-8") as f:
130130
ciphertext_manifest = json.load(f)
131131
_test_cases = []
132132

test/integration/test_i_xcompat_kms.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def _generate_test_cases():
4848
# Make no test cases if the ciphertext file is not found
4949
return []
5050

51-
with open(ciphertext_manifest_path) as f:
51+
with open(ciphertext_manifest_path, encoding="utf-8") as f:
5252
ciphertext_manifest = json.load(f)
5353
_test_cases = []
5454

@@ -69,9 +69,9 @@ def _generate_test_cases():
6969
@pytest.mark.parametrize("plaintext_filename, ciphertext_filename", _generate_test_cases())
7070
def test_decrypt_from_file(plaintext_filename, ciphertext_filename):
7171
"""Tests decrypt from known good files."""
72-
with open(ciphertext_filename, "rb") as infile:
72+
with open(ciphertext_filename, "rb", encoding="utf-8") as infile:
7373
ciphertext = infile.read()
74-
with open(plaintext_filename, "rb") as infile:
74+
with open(plaintext_filename, "rb", encoding="utf-8") as infile:
7575
plaintext = infile.read()
7676
decrypted_ciphertext, _header = aws_encryption_sdk.decrypt(
7777
source=ciphertext, key_provider=setup_kms_master_key_provider()

test/integration/test_kat_commitment.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def _file_root():
5050
base_dir = os.path.join(root_dir, "test", "resources")
5151
file_path = os.path.join(base_dir, FILE_NAME)
5252

53-
test_str = open(file_path, "r").read() # pylint: disable=consider-using-with
53+
test_str = open(file_path, "r", encoding="utf-8").read() # pylint: disable=consider-using-with
5454
test_json = json.loads(test_str)
5555
kat_tests = test_json["tests"]
5656

test/unit/test_encryption_client.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def test_client_encrypt(mocker):
5959
commitment_policy=CommitmentPolicy.FORBID_ENCRYPT_ALLOW_DECRYPT, max_encrypted_data_keys=3
6060
)
6161

62-
kwargs = dict()
62+
kwargs = {}
6363
kwargs["source"] = b"plaintext"
6464
kwargs["materials_manager"] = cmm
6565
client.encrypt(**kwargs)
@@ -77,7 +77,7 @@ def test_client_decrypt(mocker):
7777
commitment_policy=CommitmentPolicy.FORBID_ENCRYPT_ALLOW_DECRYPT, max_encrypted_data_keys=3
7878
)
7979

80-
kwargs = dict()
80+
kwargs = {}
8181
kwargs["source"] = b"ciphertext"
8282
kwargs["materials_manager"] = cmm
8383
client.decrypt(**kwargs)
@@ -94,7 +94,7 @@ def test_client_stream_encrypt(mocker, mode_string):
9494
cmm = MagicMock(__class__=CryptoMaterialsManager)
9595
client = aws_encryption_sdk.EncryptionSDKClient(commitment_policy=CommitmentPolicy.FORBID_ENCRYPT_ALLOW_DECRYPT)
9696

97-
kwargs = dict()
97+
kwargs = {}
9898
kwargs["mode"] = mode_string
9999
kwargs["source"] = b"plaintext"
100100
kwargs["materials_manager"] = cmm
@@ -113,7 +113,7 @@ def test_client_stream_decrypt(mocker, mode_string):
113113
cmm = MagicMock(__class__=CryptoMaterialsManager)
114114
client = aws_encryption_sdk.EncryptionSDKClient(commitment_policy=CommitmentPolicy.FORBID_ENCRYPT_ALLOW_DECRYPT)
115115

116-
kwargs = dict()
116+
kwargs = {}
117117
kwargs["mode"] = mode_string
118118
kwargs["source"] = b"ciphertext"
119119
kwargs["materials_manager"] = cmm
@@ -132,7 +132,7 @@ def test_client_bad_kwargs(mocker, method, key):
132132
mocker.patch.object(aws_encryption_sdk, "StreamEncryptor")
133133

134134
cmm = MagicMock(__class__=CryptoMaterialsManager)
135-
kwargs = dict()
135+
kwargs = {}
136136
kwargs[key] = "foobar"
137137
kwargs["source"] = b"ciphertext"
138138
kwargs["materials_manager"] = cmm

test/unit/test_material_managers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
(EncryptionMaterials, dict(data_encryption_key=None)),
6969
(EncryptionMaterials, dict(encrypted_data_keys=None)),
7070
(EncryptionMaterials, dict(encryption_context=None)),
71-
(EncryptionMaterials, dict(signing_key=u"not bytes or None")),
71+
(EncryptionMaterials, dict(signing_key="not bytes or None")),
7272
(DecryptionMaterialsRequest, dict(algorithm=None)),
7373
(DecryptionMaterialsRequest, dict(encrypted_data_keys=None)),
7474
(DecryptionMaterialsRequest, dict(encryption_context=None)),

test/unit/test_util_str_ops.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,17 @@ def test_to_bytes_bytes2bytes(self):
3939
assert test == b"\x3a\x00\x99"
4040

4141
def test_to_str_bytes2unicode(self):
42-
test = aws_encryption_sdk.internal.str_ops.to_str(codecs.encode(u"Предисловие", "utf-8"))
43-
assert test == u"Предисловие"
42+
test = aws_encryption_sdk.internal.str_ops.to_str(codecs.encode("Предисловие", "utf-8"))
43+
assert test == "Предисловие"
4444

4545
def test_to_str_unicode2unicode(self):
46-
test = aws_encryption_sdk.internal.str_ops.to_str(u"Предисловие")
47-
assert test == u"Предисловие"
46+
test = aws_encryption_sdk.internal.str_ops.to_str("Предисловие")
47+
assert test == "Предисловие"
4848

4949
def test_to_str_unicode2bytes(self):
50-
test = aws_encryption_sdk.internal.str_ops.to_bytes(u"Предисловие")
51-
assert test == codecs.encode(u"Предисловие", "utf-8")
50+
test = aws_encryption_sdk.internal.str_ops.to_bytes("Предисловие")
51+
assert test == codecs.encode("Предисловие", "utf-8")
5252

5353
def test_to_bytes_utf82utf8(self):
54-
test = aws_encryption_sdk.internal.str_ops.to_bytes(codecs.encode(u"Предисловие", "utf-8"))
55-
assert test == codecs.encode(u"Предисловие", "utf-8")
54+
test = aws_encryption_sdk.internal.str_ops.to_bytes(codecs.encode("Предисловие", "utf-8"))
55+
assert test == codecs.encode("Предисловие", "utf-8")

test/unit/test_utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def test_prep_stream_data_passthrough():
3535
assert_prepped_stream_identity(test, io.BytesIO)
3636

3737

38-
@pytest.mark.parametrize("source", (u"some unicode data ловие", b"\x00\x01\x02"))
38+
@pytest.mark.parametrize("source", ("some unicode data ловие", b"\x00\x01\x02"))
3939
def test_prep_stream_data_wrap(source):
4040
test = aws_encryption_sdk.internal.utils.prep_stream_data(source)
4141

test_vector_handlers/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
def read(*args):
1212
"""Read complete file contents."""
13-
return open(os.path.join(HERE, *args)).read() # pylint: disable=consider-using-with
13+
return open(os.path.join(HERE, *args), encoding="utf-8").read() # pylint: disable=consider-using-with
1414

1515

1616
def get_version():

0 commit comments

Comments
 (0)