Skip to content

Commit 6c25429

Browse files
committed
Remove unnecessary default value from dict.get
1 parent 0afdb06 commit 6c25429

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

integration/v2/test_applications.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ def test_list(self):
4848
self.assertEqual(e.body.get("error_code"), "CF-AppStoppedStatsError")
4949
env = client.v2.apps.get_env(application["metadata"]["guid"])
5050
self.assertIsNotNone(env)
51-
self.assertIsNotNone(env.get("application_env_json", None))
52-
self.assertIsNotNone(env["application_env_json"].get("VCAP_APPLICATION", None))
51+
self.assertIsNotNone(env.get("application_env_json"))
52+
self.assertIsNotNone(env["application_env_json"].get("VCAP_APPLICATION"))
5353
self.assertGreater(len(env["application_env_json"]["VCAP_APPLICATION"].get("application_uris", [])), 0)
5454
_logger.debug("env = %s", json.dumps(env))
5555
cpt += 1

main/cloudfoundry_client/client.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ def _is_token_expired(response: Response) -> bool:
205205
try:
206206
json_data = response.json()
207207
invalid_token_error = "CF-InvalidAuthToken"
208-
if json_data.get("errors", None) is not None: # V3 error response
208+
if json_data.get("errors") is not None: # V3 error response
209209
for error in json_data.get("errors"):
210210
if error.get("code", 0) == 1000 and error.get("title", "") == invalid_token_error:
211211
_logger.info("_is_token_v3_expired - true")
@@ -295,4 +295,4 @@ def _check_response(response: Response) -> Response:
295295
body = response.json()
296296
except ValueError:
297297
body = response.text
298-
raise InvalidStatusCode(HTTPStatus(response.status_code), body, response.headers.get("x-vcap-request-id", None))
298+
raise InvalidStatusCode(HTTPStatus(response.status_code), body, response.headers.get("x-vcap-request-id"))

main/cloudfoundry_client/operations/push/validation/manifest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def _absolute_path(manifest_directory: str, manifest: dict):
126126

127127
@staticmethod
128128
def _convert_environment(app_manifest: dict):
129-
environment = app_manifest.get("env", None)
129+
environment = app_manifest.get("env")
130130
if environment is not None:
131131
if type(environment) != dict:
132132
raise AssertionError("'env' entry must be a dictionary")

main/cloudfoundry_client/v3/entities.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,9 @@ def _mixin_included_resources(self, result: JsonObject) -> JsonObject:
244244
def _include_resources(self, resource: JsonObject, result: JsonObject) -> None:
245245
for relationship_name, relationship in resource.get("relationships", {}).items():
246246
relationship_guid = (relationship.get("data") or {}).get("guid")
247-
included_resources = result["included"].get(plural(relationship_name), None)
247+
included_resources = result["included"].get(plural(relationship_name))
248248
if relationship_guid is not None and included_resources is not None:
249-
included_resource = next((r for r in included_resources if relationship_guid == r.get("guid", None)), None)
249+
included_resource = next((r for r in included_resources if relationship_guid == r.get("guid")), None)
250250
if included_resource is not None:
251251
self._include_resources(included_resource, result)
252252
included = resource.setdefault("_included", {})

0 commit comments

Comments
 (0)