Skip to content

Commit f5574e5

Browse files
committed
Add annotations for cloud_manager instance variable
1 parent 04dd6a0 commit f5574e5

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

upcloud_api/server.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
from time import sleep
2-
from typing import Any, Optional
2+
from typing import TYPE_CHECKING, Any, Optional
33

44
from upcloud_api.firewall import FirewallRule
55
from upcloud_api.ip_address import IPAddress
66
from upcloud_api.storage import Storage
77
from upcloud_api.utils import try_it_n_times
88

9+
if TYPE_CHECKING:
10+
from upcloud_api import CloudManager
11+
912

1013
def login_user_block(username, ssh_keys, create_password=True):
1114
"""
@@ -24,6 +27,7 @@ def login_user_block(username, ssh_keys, create_password=True):
2427
return block
2528

2629

30+
# TODO: should this inherit from UpcloudResource too?
2731
class Server:
2832
"""
2933
Class representation of UpCloud Server instance.
@@ -32,6 +36,8 @@ class Server:
3236
with the server.field=value syntax. See __setattr__ override.
3337
"""
3438

39+
cloud_manager: 'CloudManager'
40+
3541
#
3642
# Functionality for partial immutability and repopulating the object from API.
3743
#

upcloud_api/upcloud_resource.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
from typing import TYPE_CHECKING
2+
3+
if TYPE_CHECKING:
4+
from upcloud_api import CloudManager
5+
6+
17
class UpCloudResource:
28
"""
39
Base class for all API resources.
@@ -15,6 +21,8 @@ class UpCloudResource:
1521

1622
ATTRIBUTES = {} # subclass should define this
1723

24+
cloud_manager: 'CloudManager'
25+
1826
def __init__(self, **kwargs) -> None:
1927
"""
2028
Create a resource object from a dict.

0 commit comments

Comments
 (0)