Skip to content

Commit 5848cc8

Browse files
authored
Update reqs and fix issues (#1030)
* Update reqs and fix issues * Drop python 3.7 and earlier support * More formatting fixes
1 parent a3ec96f commit 5848cc8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+346
-306
lines changed

.github/workflows/pr-ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
AWS_DEFAULT_REGION: us-east-1
1111
strategy:
1212
matrix:
13-
python: [ 3.7, 3.8, 3.9, "3.10" ]
13+
python: [ 3.8, 3.9, "3.10" ]
1414
os: [ubuntu-latest, macos-latest, windows-latest]
1515
runs-on: ${{ matrix.os }}
1616
steps:

.pylintrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ persistent=yes
99
disable=
1010
missing-docstring, # not everything needs a docstring
1111
fixme, # work in progress
12-
bad-continuation, # clashes with black
1312
duplicate-code, # finds dupes between tests and plugins
1413
too-few-public-methods, # triggers when inheriting
1514
ungrouped-imports, # clashes with isort

requirements.txt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
# better interactive session, debugger
2-
ipython>=7.7.0
3-
ipdb>=0.12
2+
ipython>=8.0.0
3+
ipdb>=0.13
44

55
# testing tools
6-
pylint==2.8.3
7-
coverage>=4.5.4
8-
pytest>=6.0.0
9-
pytest-cov>=2.7.1
10-
pytest-random-order>=1.0.4
11-
hypothesis>=4.32.3
12-
pytest-localserver>=0.5.0
6+
pylint==3.0.1
7+
coverage>=7.3.2
8+
pytest>=7.4.2
9+
pytest-cov>=4.1.0
10+
pytest-random-order>=1.1.0
11+
hypothesis>=6.87.1
12+
pytest-localserver>=0.8.0
1313

1414
# commit hooks
15-
pre-commit>=1.18.1
15+
pre-commit>=3.4.0
1616

1717
# packaging
18-
twine>=3.1.0
18+
twine>=4.0.2

setup.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ def find_version(*file_paths):
7070
"Topic :: Software Development :: Code Generators",
7171
"Operating System :: OS Independent",
7272
"Programming Language :: Python :: 3 :: Only",
73-
"Programming Language :: Python :: 3.6",
74-
"Programming Language :: Python :: 3.7",
7573
"Programming Language :: Python :: 3.8",
7674
"Programming Language :: Python :: 3.9",
7775
"Programming Language :: Python :: 3.10",

src/rpdk/core/boto_helpers.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@ def get_temporary_credentials(session, key_names=BOTO_CRED_KEYS, role_arn=None):
3939
region_name=session.region_name,
4040
)
4141
if role_arn:
42-
session_name = "CloudFormationContractTest-{:%Y%m%d%H%M%S}".format(
43-
datetime.now()
44-
)
42+
session_name = f"CloudFormationContractTest-{datetime.now():%Y%m%d%H%M%S}"
4543
try:
4644
response = sts_client.assume_role(
4745
RoleArn=role_arn, RoleSessionName=session_name, DurationSeconds=900
@@ -54,7 +52,7 @@ def get_temporary_credentials(session, key_names=BOTO_CRED_KEYS, role_arn=None):
5452
role_arn,
5553
)
5654
raise DownstreamError() from Exception(
57-
"Could not assume specified role '{}'".format(role_arn)
55+
"Could not assume specified role '{role_arn}'"
5856
)
5957
temp = response["Credentials"]
6058
creds = (temp["AccessKeyId"], temp["SecretAccessKey"], temp["SessionToken"])

src/rpdk/core/build_image.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ def setup_subparser(subparsers, parents):
5353
parser.add_argument("--image-name", help="Image name")
5454
parser.add_argument(
5555
"--executable",
56-
help="The relative path to the handler executable"
57-
" that will be built into the docker image"
58-
" (ie target/myjar.jar)",
56+
help=(
57+
"The relative path to the handler executable"
58+
" that will be built into the docker image"
59+
" (ie target/myjar.jar)"
60+
),
5961
)

src/rpdk/core/contract/hook_client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -378,9 +378,9 @@ def is_update_invocation_point(invocation_point):
378378

379379
def assert_time(self, start_time, end_time, action):
380380
timeout_in_seconds = self._timeout_in_seconds
381-
assert end_time - start_time <= timeout_in_seconds, (
382-
"Handler %r timed out." % action
383-
)
381+
assert (
382+
end_time - start_time <= timeout_in_seconds
383+
), f"Handler {action!r} timed out."
384384

385385
def _make_payload(
386386
self,
@@ -472,7 +472,7 @@ def call_and_assert(
472472
**kwargs,
473473
):
474474
if assert_status not in [HookStatus.SUCCESS, HookStatus.FAILED]:
475-
raise ValueError("Assert status {} not supported.".format(assert_status))
475+
raise ValueError(f"Assert status {assert_status} not supported.")
476476

477477
status, response = self.call(invocation_point, target, target_model, **kwargs)
478478
if assert_status == HookStatus.SUCCESS:

src/rpdk/core/contract/resource_client.py

Lines changed: 28 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ def path_exists(document, path):
125125
_prop, _resolved_path, _parent = traverse(document, path)
126126
except LookupError:
127127
return False
128-
else:
129-
return True
128+
129+
return True
130130

131131

132132
def prune_properties_from_model(model, paths):
@@ -282,18 +282,16 @@ def has_only_writable_identifiers(self):
282282
)
283283

284284
def assert_write_only_property_does_not_exist(self, resource_model):
285-
286285
error_list = []
287286
if self.write_only_paths:
288287
for write_only_property in self.write_only_paths:
289288
val = self.key_error_safe_traverse(resource_model, write_only_property)
290289
if val:
291290
error_list.append(write_only_property[1])
292291
assertion_error_message = (
293-
"The model MUST NOT return properties defined as "
294-
"writeOnlyProperties in the resource schema "
295-
"\n Write only properties in resource model : %s \n Output Resource Model : %s \n"
296-
% (error_list, resource_model)
292+
"The model MUST NOT return properties defined as writeOnlyProperties"
293+
" in the resource schema \n Write only properties in resource model :"
294+
f" {error_list} \n Output Resource Model : {resource_model} \n"
297295
)
298296
assert not any(error_list), assertion_error_message
299297

@@ -302,13 +300,13 @@ def get_metadata(self):
302300
properties = self._schema["properties"]
303301
except KeyError:
304302
return set()
305-
else:
306-
return {
307-
prop
308-
for prop in properties.keys()
309-
if "insertionOrder" in properties[prop]
310-
and properties[prop]["insertionOrder"] == "false"
311-
}
303+
304+
return {
305+
prop
306+
for prop in properties.keys()
307+
if "insertionOrder" in properties[prop]
308+
and properties[prop]["insertionOrder"] == "false"
309+
}
312310

313311
@property
314312
def strategy(self):
@@ -456,11 +454,10 @@ def compare(self, inputs, outputs):
456454

457455
def compare_model(self, inputs, outputs, path=()):
458456
assertion_error_message = (
459-
"All properties specified in the request MUST "
460-
"be present in the model returned, and they MUST"
461-
" match exactly, with the exception of properties"
462-
" defined as writeOnlyProperties in the resource schema \n Request Model : %s \n Returned Model : %s \n"
463-
% (inputs, outputs)
457+
"All properties specified in the request MUST be present in the model"
458+
" returned, and they MUST match exactly, with the exception of properties"
459+
" defined as writeOnlyProperties in the resource schema \n Request Model :"
460+
f" {inputs} \n Returned Model : {outputs} \n"
464461
)
465462
try:
466463
if isinstance(inputs, dict):
@@ -488,13 +485,9 @@ def compare_model(self, inputs, outputs, path=()):
488485
else:
489486
if inputs[key] != outputs[key]:
490487
assertion_error_message = (
491-
"%s Value for property %s in Request Model(%s) and Response Model(%s) does not match"
492-
% (
493-
assertion_error_message,
494-
key,
495-
inputs[key],
496-
outputs[key],
497-
)
488+
f"{assertion_error_message} Value for property {key} in"
489+
f" Request Model({inputs[key]}) and Response"
490+
f" Model({outputs[key]}) does not match"
498491
)
499492
assert inputs[key] == outputs[key], assertion_error_message
500493
else:
@@ -612,9 +605,9 @@ def assert_time(self, start_time, end_time, action):
612605
if action in (Action.READ, Action.LIST)
613606
else self._timeout_in_seconds * 2
614607
)
615-
assert end_time - start_time <= timeout_in_seconds, (
616-
"Handler %r timed out." % action
617-
)
608+
assert (
609+
end_time - start_time <= timeout_in_seconds
610+
), f"Handler {action!r} timed out."
618611

619612
@staticmethod
620613
def assert_primary_identifier(primary_identifier_paths, resource_model):
@@ -646,8 +639,8 @@ def is_primary_identifier_equal(
646639
)
647640
except KeyError as e:
648641
raise AssertionError(
649-
"The primaryIdentifier returned in every progress event must\
650-
match the primaryIdentifier passed into the request"
642+
"The primaryIdentifier returned in every progress event must "
643+
"match the primaryIdentifier passed into the request"
651644
) from e
652645

653646
@staticmethod
@@ -662,8 +655,8 @@ def get_primary_identifier(primary_identifier_path, model):
662655
return pid_list
663656
except KeyError as e:
664657
raise AssertionError(
665-
"The primaryIdentifier returned in every progress event must\
666-
match the primaryIdentifier passed into the request \n"
658+
"The primaryIdentifier returned in every progress event must "
659+
"match the primaryIdentifier passed into the request \n"
667660
) from e
668661

669662
def _make_payload(
@@ -761,7 +754,7 @@ def call_and_assert(
761754
if not self.has_required_handlers():
762755
raise ValueError("Create/Read/Delete handlers are required")
763756
if assert_status not in [OperationStatus.SUCCESS, OperationStatus.FAILED]:
764-
raise ValueError("Assert status {} not supported.".format(assert_status))
757+
raise ValueError(f"Assert status {assert_status} not supported.")
765758

766759
status, response = self.call(action, current_model, previous_model, **kwargs)
767760
if assert_status == OperationStatus.SUCCESS:
@@ -857,7 +850,7 @@ def validate_model_contain_tags(self, inputs):
857850
if key == tag_property_name:
858851
return True
859852
else:
860-
raise assertion_error_message
853+
raise AssertionError(assertion_error_message)
861854
except Exception as exception:
862855
raise AssertionError(assertion_error_message) from exception
863856
return False

src/rpdk/core/contract/suite/hook/hook_handler_commons.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@
2424
def test_hook_success(hook_client, invocation_point, target, target_model):
2525
if HookClient.is_update_invocation_point(invocation_point):
2626
raise ValueError(
27-
"Invocation point {} not supported for this testing operation".format(
28-
invocation_point
29-
)
27+
f"Invocation point {invocation_point} not supported for this testing"
28+
" operation"
3029
)
3130

3231
_status, response, _error_code = hook_client.call_and_assert(
@@ -39,9 +38,8 @@ def test_hook_success(hook_client, invocation_point, target, target_model):
3938
def test_update_hook_success(hook_client, invocation_point, target, target_model):
4039
if not HookClient.is_update_invocation_point(invocation_point):
4140
raise ValueError(
42-
"Invocation point {} not supported for testing UPDATE hook operation".format(
43-
invocation_point
44-
)
41+
f"Invocation point {invocation_point} not supported for testing UPDATE hook"
42+
" operation"
4543
)
4644

4745
_status, response, _error_code = hook_client.call_and_assert(
@@ -85,7 +83,10 @@ def test_hook_handlers_failed(hook_client, invocation_point):
8583

8684
@failed_event(
8785
error_code=HandlerErrorCode.UnsupportedTarget,
88-
msg="A hook handler MUST return FAILED with a UnsupportedTarget error code if the target is not supported",
86+
msg=(
87+
"A hook handler MUST return FAILED with a UnsupportedTarget error code if the"
88+
" target is not supported"
89+
),
8990
)
9091
def test_hook_unsupported_target(hook_client, invocation_point):
9192
if not hook_client.handler_has_wildcard_targets(invocation_point):

src/rpdk/core/contract/suite/resource/contract_asserts.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ def response_contains_resource_model_equal_updated_model(
1515
assert response["resourceModel"] == {
1616
**current_resource_model,
1717
**update_resource_model,
18-
}, "All properties specified in the update request MUST be present in the \
19-
model returned, and they MUST match exactly, with the exception of \
20-
properties defined as writeOnlyProperties in the resource schema"
18+
}, (
19+
"All properties specified in the update request MUST be present in the "
20+
"model returned, and they MUST match exactly, with the exception of "
21+
"properties defined as writeOnlyProperties in the resource schema"
22+
)
2123

2224

2325
@decorate()
@@ -35,8 +37,10 @@ def response_contains_unchanged_primary_identifier(
3537
resource_client.primary_identifier_paths,
3638
current_resource_model,
3739
response["resourceModel"],
38-
), "PrimaryIdentifier returned in every progress event must match \
39-
the primaryIdentifier passed into the request"
40+
), (
41+
"PrimaryIdentifier returned in every progress event must match the"
42+
" primaryIdentifier passed into the request"
43+
)
4044

4145

4246
@decorate(after=False)

0 commit comments

Comments
 (0)