Skip to content

Commit b91e44b

Browse files
authored
chore: apply changes to accomodate updated Pylint checks (#295)
* chore: update pylintrc with new Python3-only checks * chore: decrypt oracle is Python3-only * chore: apply recommendations for Python 3 updates to super and error chaining
1 parent 97d9468 commit b91e44b

File tree

9 files changed

+23
-12
lines changed

9 files changed

+23
-12
lines changed

decrypt_oracle/.chalice/pipeline.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def __init__(self, *args, **kwargs):
3737
"""Set up override values."""
3838
my_kwargs = dict(Effect=AWS.Allow, Resource=["*"])
3939
my_kwargs.update(kwargs)
40-
super(AllowEverywhere, self).__init__(*args, **my_kwargs)
40+
super().__init__(*args, **my_kwargs)
4141

4242

4343
def _service_assume_role(service: str) -> AWS.Policy:

decrypt_oracle/src/aws_encryption_sdk_decrypt_oracle/key_providers/counting.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class CountingMasterKeyConfig(MasterKeyConfig):
3030

3131
def __init__(self) -> None:
3232
"""Set the key id to "test_counting_prov_info"."""
33-
super(CountingMasterKeyConfig, self).__init__(key_id=b"test_counting_prov_info")
33+
super().__init__(key_id=b"test_counting_prov_info")
3434

3535

3636
class CountingMasterKey(MasterKey):

decrypt_oracle/src/aws_encryption_sdk_decrypt_oracle/key_providers/null.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class NullMasterKeyConfig(MasterKeyConfig):
2626

2727
def __init__(self) -> None:
2828
"""Set the key id to "null"."""
29-
super(NullMasterKeyConfig, self).__init__(key_id=b"null")
29+
super().__init__(key_id=b"null")
3030

3131

3232
class NullMasterKey(MasterKey):

decrypt_oracle/src/pylintrc

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
disable =
44
bad-continuation, # we let black handle this
55
ungrouped-imports, # we let isort handle this
6-
useless-object-inheritance, # we need to support Python 2, so no, not useless
76

87
[FORMAT]
98
max-line-length = 120

decrypt_oracle/test/integration/integration_test_utils.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ def decrypt_endpoint() -> Text:
3838
try:
3939
deployment_id = os.environ[DEPLOYMENT_ID]
4040
region = os.environ[DEPLOYMENT_REGION]
41-
except KeyError:
41+
except KeyError as error:
4242
raise ValueError(
4343
(
4444
'Environment variables "{region}" and "{deployment}" '
4545
"must be set to the correct values for the deployed decrypt oracle."
4646
).format(region=DEPLOYMENT_REGION, deployment=DEPLOYMENT_ID)
47-
)
47+
) from error
4848

4949
_ENDPOINT = "https://{deployment_id}.execute-api.{region}.amazonaws.com/api/v0/decrypt".format(
5050
deployment_id=deployment_id, region=region
@@ -56,12 +56,12 @@ def get_cmk_arn() -> Text:
5656
"""Retrieve the target CMK ARN from environment variable."""
5757
try:
5858
arn = os.environ[AWS_KMS_KEY_ID]
59-
except KeyError:
59+
except KeyError as error:
6060
raise ValueError(
6161
'Environment variable "{}" must be set to a valid KMS CMK ARN for integration tests to run'.format(
6262
AWS_KMS_KEY_ID
6363
)
64-
)
64+
) from error
6565

6666
if arn.startswith("arn:") and ":alias/" not in arn:
6767
return arn

src/pylintrc

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@ disable =
55
ungrouped-imports, # we let isort handle this
66
no-member, # breaks with attrs
77
no-self-use, # interesting to keep in mind for later refactoring, but not blocking
8-
useless-object-inheritance, # we need to support Python 2, so no, not useless
98
too-few-public-methods, # does not allow value stores
109
no-else-return, # we omit this on purpose for brevity where it would add no value
1110
attribute-defined-outside-init, # breaks with attrs_post_init
1211
abstract-method, # throws false positives on io.BaseIO grandchildren
1312
redefined-outer-name, # we do this on purpose in multiple places
13+
# All below are disabled because we need to support Python 2
14+
useless-object-inheritance,
15+
raise-missing-from,
16+
super-with-arguments,
1417

1518
[BASIC]
1619
# Allow function names up to 50 characters

test/pylintrc

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ disable =
88
abstract-class-instantiated, # we do this on purpose to test that they are enforced
99
no-member, # raised on patched objects with mock checks
1010
no-self-use, # common pattern when using pytest classes: can be enabled once all tests are refactored to pytest functions
11-
useless-object-inheritance, # we need to support Python 2, so no, not useless
1211
duplicate-code, # unit tests for similar things tend to be similar
1312
too-many-instance-attributes, # common pattern when using pytest classes: can be enabled once all tests are refactored to pytest functions
1413
too-few-public-methods, # common when setting up mock classes
@@ -19,6 +18,10 @@ disable =
1918
abstract-method, # we do this on purpose to test that they are enforced
2019
redefined-outer-name, # raised when using decorators
2120
unused-argument, # raised when patches are needed but not called
21+
# All below are disabled because we need to support Python 2
22+
useless-object-inheritance,
23+
raise-missing-from,
24+
super-with-arguments,
2225

2326
[VARIABLES]
2427
additional-builtins = raw_input

test_vector_handlers/src/pylintrc

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33
disable =
44
bad-continuation, # we let black handle this
55
ungrouped-imports, # we let isort handle this
6-
useless-object-inheritance, # we need to support Python 2, so no, not useless
76
duplicate-code, # the manifest handlers have a lot of similar code
7+
# All below are disabled because we need to support Python 2
8+
useless-object-inheritance,
9+
raise-missing-from,
10+
super-with-arguments,
811

912
[FORMAT]
1013
max-line-length = 120

test_vector_handlers/test/pylintrc

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@ disable =
55
missing-docstring, # we don't write docstrings for tests
66
bad-continuation, # we let black handle this
77
ungrouped-imports, # we let isort handle this
8-
useless-object-inheritance, # we need to support Python 2, so no, not useless
98
duplicate-code, # unit tests for similar things tend to be similar
109
redefined-outer-name, # raised when using decorators
10+
# All below are disabled because we need to support Python 2
11+
useless-object-inheritance,
12+
raise-missing-from,
13+
super-with-arguments,
1114

1215
[FORMAT]
1316
max-line-length = 120

0 commit comments

Comments
 (0)