8
8
import string
9
9
import subprocess
10
10
import tempfile
11
- from typing import Dict , List , Optional , Set
12
11
13
12
import juju .unit
14
13
import yaml
@@ -133,7 +132,7 @@ async def get_primary_unit(
133
132
return primary_unit
134
133
135
134
136
- async def get_server_config_credentials (unit : Unit ) -> Dict :
135
+ async def get_server_config_credentials (unit : Unit ) -> dict :
137
136
"""Helper to run an action to retrieve server config credentials.
138
137
139
138
Args:
@@ -145,7 +144,7 @@ async def get_server_config_credentials(unit: Unit) -> Dict:
145
144
return await juju_ .run_action (unit , "get-password" , username = SERVER_CONFIG_USERNAME )
146
145
147
146
148
- async def fetch_credentials (unit : Unit , username : str = None ) -> Dict :
147
+ async def fetch_credentials (unit : Unit , username : str = None ) -> dict :
149
148
"""Helper to run an action to fetch credentials.
150
149
151
150
Args:
@@ -159,7 +158,7 @@ async def fetch_credentials(unit: Unit, username: str = None) -> Dict:
159
158
return await juju_ .run_action (unit , "get-password" , username = username )
160
159
161
160
162
- async def rotate_credentials (unit : Unit , username : str = None , password : str = None ) -> Dict :
161
+ async def rotate_credentials (unit : Unit , username : str = None , password : str = None ) -> dict :
163
162
"""Helper to run an action to rotate credentials.
164
163
165
164
Args:
@@ -176,7 +175,7 @@ async def rotate_credentials(unit: Unit, username: str = None, password: str = N
176
175
return await juju_ .run_action (unit , "set-password" , username = username , password = password )
177
176
178
177
179
- async def get_legacy_mysql_credentials (unit : Unit ) -> Dict :
178
+ async def get_legacy_mysql_credentials (unit : Unit ) -> dict :
180
179
"""Helper to run an action to retrieve legacy mysql config credentials.
181
180
182
181
Args:
@@ -189,7 +188,7 @@ async def get_legacy_mysql_credentials(unit: Unit) -> Dict:
189
188
190
189
191
190
@retry (stop = stop_after_attempt (20 ), wait = wait_fixed (5 ), reraise = True )
192
- async def get_system_user_password (unit : Unit , user : str ) -> Dict :
191
+ async def get_system_user_password (unit : Unit , user : str ) -> dict :
193
192
"""Helper to run an action to retrieve system user password.
194
193
195
194
Args:
@@ -206,10 +205,10 @@ async def execute_queries_on_unit(
206
205
unit_address : str ,
207
206
username : str ,
208
207
password : str ,
209
- queries : List [str ],
208
+ queries : list [str ],
210
209
commit : bool = False ,
211
210
raw : bool = False ,
212
- ) -> List :
211
+ ) -> list :
213
212
"""Execute given MySQL queries on a unit.
214
213
215
214
Args:
@@ -271,7 +270,7 @@ def is_relation_broken(ops_test: OpsTest, endpoint_one: str, endpoint_two: str)
271
270
272
271
@retry (stop = stop_after_attempt (30 ), wait = wait_fixed (5 ), reraise = True )
273
272
def is_connection_possible (
274
- credentials : Dict , * , retry_if_not_possible = False , ** extra_opts
273
+ credentials : dict , * , retry_if_not_possible = False , ** extra_opts
275
274
) -> bool :
276
275
"""Test a connection to a MySQL server.
277
276
@@ -544,7 +543,7 @@ async def get_relation_data(
544
543
return relation_data
545
544
546
545
547
- def get_read_only_endpoints (relation_data : list ) -> Set [str ]:
546
+ def get_read_only_endpoints (relation_data : list ) -> set [str ]:
548
547
"""Returns the read-only-endpoints from the relation data.
549
548
550
549
Args:
@@ -573,8 +572,8 @@ def get_read_only_endpoints(relation_data: list) -> Set[str]:
573
572
574
573
575
574
async def get_leader_unit (
576
- ops_test : Optional [ OpsTest ] , app_name : str , model : Optional [ Model ] = None
577
- ) -> Optional [ Unit ] :
575
+ ops_test : OpsTest | None , app_name : str , model : Model | None = None
576
+ ) -> Unit | None :
578
577
"""Get the leader unit of a given application.
579
578
580
579
Args:
@@ -593,7 +592,7 @@ async def get_leader_unit(
593
592
return leader_unit
594
593
595
594
596
- def get_read_only_endpoint_ips (relation_data : list ) -> List [str ]:
595
+ def get_read_only_endpoint_ips (relation_data : list ) -> list [str ]:
597
596
"""Returns the read-only-endpoint hostnames from the relation data.
598
597
599
598
Args:
@@ -640,7 +639,7 @@ async def remove_leader_unit(ops_test: OpsTest, application_name: str):
640
639
)
641
640
642
641
643
- async def get_units_ip_addresses (ops_test : OpsTest , app_name : str ) -> List [str ]:
642
+ async def get_units_ip_addresses (ops_test : OpsTest , app_name : str ) -> list [str ]:
644
643
"""Retrieves hostnames of given application units.
645
644
646
645
Args:
@@ -810,12 +809,12 @@ async def unit_file_md5(ops_test: OpsTest, unit_name: str, file_path: str) -> st
810
809
return None
811
810
812
811
813
- async def get_cluster_status (unit : Unit , cluster_set : Optional [ bool ] = False ) -> Dict :
812
+ async def get_cluster_status (unit : Unit , cluster_set : bool | None = False ) -> dict :
814
813
"""Get the cluster status by running the get-cluster-status action.
815
814
816
815
Args:
817
- ops_test: The ops test framework
818
816
unit: The unit on which to execute the action on
817
+ cluster_set: Whether to get the cluster-set instead
819
818
820
819
Returns:
821
820
A dictionary representing the cluster status
@@ -978,9 +977,7 @@ def get_unit_by_index(app_name: str, units: list, index: int):
978
977
return unit
979
978
980
979
981
- async def get_status_log (
982
- ops_test : OpsTest , unit_name : str , num_logs : Optional [int ] = None
983
- ) -> list :
980
+ async def get_status_log (ops_test : OpsTest , unit_name : str , num_logs : int | None = None ) -> list :
984
981
"""Get the status log for a unit.
985
982
986
983
Args:
0 commit comments