Skip to content

Commit b91f188

Browse files
fix: Ensure all arguments with None defaults are marked as optional (#459)
* Ensure all arguments with None defaults are marked as optional * Fix import issue
1 parent 35416b5 commit b91f188

File tree

10 files changed

+29
-25
lines changed

10 files changed

+29
-25
lines changed

linode_api4/groups/image.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ def __call__(self, *filters):
3232
def create(
3333
self,
3434
disk: Union[Disk, int],
35-
label: str = None,
36-
description: str = None,
35+
label: Optional[str] = None,
36+
description: Optional[str] = None,
3737
cloud_init: bool = False,
3838
tags: Optional[List[str]] = None,
3939
):
@@ -82,7 +82,7 @@ def create_upload(
8282
self,
8383
label: str,
8484
region: str,
85-
description: str = None,
85+
description: Optional[str] = None,
8686
cloud_init: bool = False,
8787
tags: Optional[List[str]] = None,
8888
) -> Tuple[Image, str]:
@@ -132,7 +132,7 @@ def upload(
132132
label: str,
133133
region: str,
134134
file: BinaryIO,
135-
description: str = None,
135+
description: Optional[str] = None,
136136
tags: Optional[List[str]] = None,
137137
) -> Image:
138138
"""

linode_api4/groups/polling.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from typing import Optional
2+
13
import polling
24

35
from linode_api4.groups import Group
@@ -13,7 +15,7 @@ def event_poller_create(
1315
self,
1416
entity_type: str,
1517
action: str,
16-
entity_id: int = None,
18+
entity_id: Optional[int] = None,
1719
) -> EventPoller:
1820
"""
1921
Creates a new instance of the EventPoller class.

linode_api4/linode_client.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import json
44
import logging
55
from importlib.metadata import version
6-
from typing import BinaryIO, List, Tuple
6+
from typing import BinaryIO, List, Optional, Tuple
77
from urllib import parse
88

99
import requests
@@ -391,8 +391,8 @@ def image_create_upload(
391391
self,
392392
label: str,
393393
region: str,
394-
description: str = None,
395-
tags: List[str] = None,
394+
description: Optional[str] = None,
395+
tags: Optional[List[str]] = None,
396396
) -> Tuple[Image, str]:
397397
"""
398398
.. note:: This method is an alias to maintain backwards compatibility.
@@ -409,8 +409,8 @@ def image_upload(
409409
label: str,
410410
region: str,
411411
file: BinaryIO,
412-
description: str = None,
413-
tags: List[str] = None,
412+
description: Optional[str] = None,
413+
tags: Optional[List[str]] = None,
414414
) -> Image:
415415
"""
416416
.. note:: This method is an alias to maintain backwards compatibility.

linode_api4/objects/image.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from dataclasses import dataclass
2-
from typing import List, Union
2+
from typing import List, Optional, Union
33

44
from linode_api4.objects import Base, Property, Region
55
from linode_api4.objects.serializable import JSONObject, StrEnum
@@ -25,7 +25,7 @@ class ImageRegion(JSONObject):
2525
"""
2626

2727
region: str = ""
28-
status: ReplicationStatus = None
28+
status: Optional[ReplicationStatus] = None
2929

3030

3131
class Image(Base):

linode_api4/objects/lke.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ class LKEClusterControlPlaneACLAddresses(JSONObject):
103103
to access an LKE cluster's control plane.
104104
"""
105105

106-
ipv4: List[str] = None
107-
ipv6: List[str] = None
106+
ipv4: Optional[List[str]] = None
107+
ipv6: Optional[List[str]] = None
108108

109109

110110
@dataclass
@@ -117,7 +117,7 @@ class LKEClusterControlPlaneACL(JSONObject):
117117
"""
118118

119119
enabled: bool = False
120-
addresses: LKEClusterControlPlaneACLAddresses = None
120+
addresses: Optional[LKEClusterControlPlaneACLAddresses] = None
121121

122122

123123
class LKENodePoolNode:
@@ -351,7 +351,7 @@ def node_pool_create(
351351
self,
352352
node_type: Union[Type, str],
353353
node_count: int,
354-
labels: Dict[str, str] = None,
354+
labels: Optional[Dict[str, str]] = None,
355355
taints: List[Union[LKENodePoolTaint, Dict[str, Any]]] = None,
356356
**kwargs,
357357
):

linode_api4/objects/region.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from dataclasses import dataclass
2-
from typing import List
2+
from typing import List, Optional
33

44
from linode_api4.errors import UnexpectedResponseError
55
from linode_api4.objects.base import Base, JSONObject, Property
@@ -59,6 +59,6 @@ class RegionAvailabilityEntry(JSONObject):
5959
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-region-availability
6060
"""
6161

62-
region: str = None
63-
plan: str = None
62+
region: Optional[str] = None
63+
plan: Optional[str] = None
6464
available: bool = False

linode_api4/objects/vpc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class VPCSubnetLinodeInterface(JSONObject):
1616
@dataclass
1717
class VPCSubnetLinode(JSONObject):
1818
id: int = 0
19-
interfaces: List[VPCSubnetLinodeInterface] = None
19+
interfaces: Optional[List[VPCSubnetLinodeInterface]] = None
2020

2121

2222
class VPCSubnet(DerivedBase):

linode_api4/polling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def __init__(
104104
client: "LinodeClient",
105105
entity_type: str,
106106
action: str,
107-
entity_id: int = None,
107+
entity_id: Optional[int] = None,
108108
):
109109
self._client = client
110110
self._entity_type = entity_type

test/integration/conftest.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import os
33
import random
44
import time
5-
from typing import Set
5+
from typing import Optional, Set
66

77
import pytest
88
import requests
@@ -35,7 +35,9 @@ def get_random_label():
3535

3636

3737
def get_regions(
38-
client: LinodeClient, capabilities: Set[str] = None, site_type: str = None
38+
client: LinodeClient,
39+
capabilities: Optional[Set[str]] = None,
40+
site_type: Optional[str] = None,
3941
):
4042
region_override = os.environ.get(ENV_REGION_OVERRIDE)
4143

test/unit/objects/image_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from datetime import datetime
22
from io import BytesIO
33
from test.unit.base import ClientBaseCase
4-
from typing import BinaryIO
4+
from typing import BinaryIO, Optional
55
from unittest.mock import patch
66

77
from linode_api4.objects import Image, Region
@@ -95,7 +95,7 @@ def test_image_upload(self):
9595
Test that an image can be uploaded.
9696
"""
9797

98-
def put_mock(url: str, data: BinaryIO = None, **kwargs):
98+
def put_mock(url: str, data: Optional[BinaryIO] = None, **kwargs):
9999
self.assertEqual(url, "https://linode.com/")
100100
self.assertEqual(data.read(), TEST_IMAGE_CONTENT)
101101

0 commit comments

Comments
 (0)