diff --git a/linode_api4/groups/linode.py b/linode_api4/groups/linode.py index c20a033a3..11cde8022 100644 --- a/linode_api4/groups/linode.py +++ b/linode_api4/groups/linode.py @@ -295,9 +295,11 @@ def instance_create( params = { "type": ltype.id if issubclass(type(ltype), Base) else ltype, "region": region.id if issubclass(type(region), Base) else region, - "image": (image.id if issubclass(type(image), Base) else image) - if image - else None, + "image": ( + (image.id if issubclass(type(image), Base) else image) + if image + else None + ), "authorized_keys": authorized_keys, } diff --git a/linode_api4/groups/lke.py b/linode_api4/groups/lke.py index ac03155a7..60ec480b5 100644 --- a/linode_api4/groups/lke.py +++ b/linode_api4/groups/lke.py @@ -93,9 +93,11 @@ def cluster_create(self, region, label, node_pools, kube_version, **kwargs): for c in node_pools: if isinstance(c, dict): new_pool = { - "type": c["type"].id - if "type" in c and issubclass(type(c["type"]), Base) - else c.get("type"), + "type": ( + c["type"].id + if "type" in c and issubclass(type(c["type"]), Base) + else c.get("type") + ), "count": c.get("count"), } @@ -105,9 +107,11 @@ def cluster_create(self, region, label, node_pools, kube_version, **kwargs): "label": label, "region": region.id if issubclass(type(region), Base) else region, "node_pools": pools, - "k8s_version": kube_version.id - if issubclass(type(kube_version), Base) - else kube_version, + "k8s_version": ( + kube_version.id + if issubclass(type(kube_version), Base) + else kube_version + ), } params.update(kwargs) diff --git a/linode_api4/groups/networking.py b/linode_api4/groups/networking.py index a226874ef..606435422 100644 --- a/linode_api4/groups/networking.py +++ b/linode_api4/groups/networking.py @@ -310,9 +310,9 @@ def ip_addresses_share(self, ips, linode): params = { "ips": shared_ips, - "linode_id": linode - if not isinstance(linode, Instance) - else linode.id, + "linode_id": ( + linode if not isinstance(linode, Instance) else linode.id + ), } self.client.post("/networking/ips/share", model=self, data=params) diff --git a/linode_api4/groups/obj.py b/linode_api4/groups/obj.py index aae2c6ae2..2ca2f0b6c 100644 --- a/linode_api4/groups/obj.py +++ b/linode_api4/groups/obj.py @@ -104,9 +104,12 @@ def keys_create(self, label, bucket_access=None): { "permissions": c.get("permissions"), "bucket_name": c.get("bucket_name"), - "cluster": c.id - if "cluster" in c and issubclass(type(c["cluster"]), Base) - else c.get("cluster"), + "cluster": ( + c.id + if "cluster" in c + and issubclass(type(c["cluster"]), Base) + else c.get("cluster") + ), } for c in bucket_access ] diff --git a/linode_api4/groups/object_storage.py b/linode_api4/groups/object_storage.py index df6ba2006..1e5fca65f 100644 --- a/linode_api4/groups/object_storage.py +++ b/linode_api4/groups/object_storage.py @@ -114,9 +114,12 @@ def keys_create(self, label, bucket_access=None): { "permissions": c.get("permissions"), "bucket_name": c.get("bucket_name"), - "cluster": c.id - if "cluster" in c and issubclass(type(c["cluster"]), Base) - else c.get("cluster"), + "cluster": ( + c.id + if "cluster" in c + and issubclass(type(c["cluster"]), Base) + else c.get("cluster") + ), } for c in bucket_access ] diff --git a/linode_api4/groups/volume.py b/linode_api4/groups/volume.py index 032a04c3b..b27ebf8ba 100644 --- a/linode_api4/groups/volume.py +++ b/linode_api4/groups/volume.py @@ -56,9 +56,9 @@ def create(self, label, region=None, linode=None, size=20, **kwargs): "label": label, "size": size, "region": region.id if issubclass(type(region), Base) else region, - "linode_id": linode.id - if issubclass(type(linode), Base) - else linode, + "linode_id": ( + linode.id if issubclass(type(linode), Base) else linode + ), } params.update(kwargs) diff --git a/linode_api4/objects/linode.py b/linode_api4/objects/linode.py index d771aaeeb..9fcdae113 100644 --- a/linode_api4/objects/linode.py +++ b/linode_api4/objects/linode.py @@ -82,9 +82,9 @@ def restore_to(self, linode, **kwargs): """ d = { - "linode_id": linode.id - if issubclass(type(linode), Base) - else linode, + "linode_id": ( + linode.id if issubclass(type(linode), Base) else linode + ), } d.update(kwargs) @@ -379,9 +379,11 @@ def _serialize(self): "purpose": "vpc", "primary": self.primary, "subnet_id": self.subnet_id, - "ipv4": self.ipv4.dict - if isinstance(self.ipv4, ConfigInterfaceIPv4) - else self.ipv4, + "ipv4": ( + self.ipv4.dict + if isinstance(self.ipv4, ConfigInterfaceIPv4) + else self.ipv4 + ), "ip_ranges": self.ip_ranges, }, } @@ -1117,9 +1119,11 @@ def config_create( params = { "kernel": kernel.id if issubclass(type(kernel), Base) else kernel, - "label": label - if label - else "{}_config_{}".format(self.label, len(self.configs)), + "label": ( + label + if label + else "{}_config_{}".format(self.label, len(self.configs)) + ), "devices": device_map, "interfaces": param_interfaces, } @@ -1190,9 +1194,11 @@ def disk_create( params = { "size": size, - "label": label - if label - else "{}_disk_{}".format(self.label, len(self.disks)), + "label": ( + label + if label + else "{}_disk_{}".format(self.label, len(self.disks)) + ), "read_only": read_only, "filesystem": filesystem, "authorized_keys": authorized_keys, @@ -1202,9 +1208,9 @@ def disk_create( if image: params.update( { - "image": image.id - if issubclass(type(image), Base) - else image, + "image": ( + image.id if issubclass(type(image), Base) else image + ), "root_pass": root_pass, } ) @@ -1629,13 +1635,15 @@ def clone( dids = [d.id if issubclass(type(d), Base) else d for d in disks] params = { - "linode_id": to_linode.id - if issubclass(type(to_linode), Base) - else to_linode, + "linode_id": ( + to_linode.id if issubclass(type(to_linode), Base) else to_linode + ), "region": region.id if issubclass(type(region), Base) else region, - "type": instance_type.id - if issubclass(type(instance_type), Base) - else instance_type, + "type": ( + instance_type.id + if issubclass(type(instance_type), Base) + else instance_type + ), "configs": cids if cids else None, "disks": dids if dids else None, "label": label, diff --git a/linode_api4/objects/lke.py b/linode_api4/objects/lke.py index 647080f44..2e24b76f7 100644 --- a/linode_api4/objects/lke.py +++ b/linode_api4/objects/lke.py @@ -83,9 +83,11 @@ def _populate(self, json): """ if json is not None and json != {}: new_nodes = [ - LKENodePoolNode(self._client, c) - if not isinstance(c, dict) - else c + ( + LKENodePoolNode(self._client, c) + if not isinstance(c, dict) + else c + ) for c in json["nodes"] ] json["nodes"] = new_nodes diff --git a/linode_api4/objects/volume.py b/linode_api4/objects/volume.py index c40619187..d572c12f5 100644 --- a/linode_api4/objects/volume.py +++ b/linode_api4/objects/volume.py @@ -45,14 +45,16 @@ def attach(self, to_linode, config=None): "{}/attach".format(Volume.api_endpoint), model=self, data={ - "linode_id": to_linode.id - if issubclass(type(to_linode), Base) - else to_linode, - "config": None - if not config - else config.id - if issubclass(type(config), Base) - else config, + "linode_id": ( + to_linode.id + if issubclass(type(to_linode), Base) + else to_linode + ), + "config": ( + None + if not config + else config.id if issubclass(type(config), Base) else config + ), }, ) diff --git a/linode_api4/util.py b/linode_api4/util.py index 3a96fbc05..1ddbcc25b 100644 --- a/linode_api4/util.py +++ b/linode_api4/util.py @@ -1,6 +1,7 @@ """ Contains various utility functions. """ + from typing import Any, Dict