33import os
44import copy
55import re
6- from typing import Any
6+ from typing import Any , List , Set , Dict , Optional
77
88from . import base
99from .. import api
@@ -100,7 +100,7 @@ def load_template_records_from_file(file_path: str) -> list:
100100TRANSFER_RECORD_SUCCESS = "transfer_record_success"
101101
102102
103- def _substitute_value (value : str , values : dict [str , str ]) -> str :
103+ def _substitute_value (value : str , values : Dict [str , str ]) -> str :
104104 """Replace all ${key} placeholders in a string with values from the given dict."""
105105 result = value
106106 while True :
@@ -113,7 +113,7 @@ def _substitute_value(value: str, values: dict[str, str]) -> str:
113113 return result
114114
115115
116- def _substitute_in_dict (container : dict , values : dict [str , str ]) -> None :
116+ def _substitute_in_dict (container : Dict , values : Dict [str , str ]) -> None :
117117 """Recursively substitute placeholders in dict (and nested dicts/lists) in place."""
118118 for key , val in list (container .items ()):
119119 if isinstance (val , str ):
@@ -126,7 +126,7 @@ def _substitute_in_dict(container: dict, values: dict[str, str]) -> None:
126126 container [key ] = _substitute_in_list (val , values )
127127
128128
129- def _substitute_in_list (container : list , values : dict [str , str ]) -> list :
129+ def _substitute_in_list (container : list , values : Dict [str , str ]) -> List :
130130 """Return a new list with placeholders substituted."""
131131 result = []
132132 for item in container :
@@ -142,7 +142,7 @@ def _substitute_in_list(container: list, values: dict[str, str]) -> list:
142142 return result
143143
144144
145- def _get_substitution_values (enterprise : enterprise_types .IEnterpriseData , email : str ) -> dict [str , str ]:
145+ def _get_substitution_values (enterprise : enterprise_types .IEnterpriseData , email : str ) -> Dict [str , str ]:
146146 """Build substitution map for a user: user_email, user_name, generate_password."""
147147 values = {
148148 "user_email" : email ,
@@ -156,14 +156,14 @@ def _get_substitution_values(enterprise: enterprise_types.IEnterpriseData, email
156156
157157
158158def _substitute_record_params (
159- enterprise : enterprise_types .IEnterpriseData , email : str , record_data : dict
159+ enterprise : enterprise_types .IEnterpriseData , email : str , record_data : Dict
160160) -> None :
161161 """Fill template parameters in record_data for the given user (in place)."""
162162 values = _get_substitution_values (enterprise , email )
163163 _substitute_in_dict (record_data , values )
164164
165165
166- def _resolve_user_to_email (enterprise : enterprise_types .IEnterpriseData , user_id : str ) -> str | None :
166+ def _resolve_user_to_email (enterprise : enterprise_types .IEnterpriseData , user_id : str ) -> Optional [ str ] :
167167 """Resolve user identifier (email, name, or enterprise_user_id) to username (email)."""
168168 user_id_lower = user_id .lower ()
169169 for u in enterprise .users .get_all_entities ():
@@ -176,7 +176,7 @@ def _resolve_user_to_email(enterprise: enterprise_types.IEnterpriseData, user_id
176176 return None
177177
178178
179- def _resolve_team_to_uid (enterprise : enterprise_types .IEnterpriseData , team_id : str ) -> str | None :
179+ def _resolve_team_to_uid (enterprise : enterprise_types .IEnterpriseData , team_id : str ) -> Optional [ str ] :
180180 """Resolve team identifier (name or team_uid) to team_uid."""
181181 for t in enterprise .teams .get_all_entities () or []:
182182 if team_id == t .team_uid or team_id .lower () == t .name .lower ():
@@ -187,9 +187,9 @@ def _resolve_team_to_uid(enterprise: enterprise_types.IEnterpriseData, team_id:
187187def _collect_recipient_emails (
188188 enterprise : enterprise_types .IEnterpriseData ,
189189 current_username : str ,
190- user_ids : list [str ],
191- team_ids : list [str ],
192- ) -> set [str ]:
190+ user_ids : List [str ],
191+ team_ids : List [str ],
192+ ) -> Set [str ]:
193193 """Resolve user_ids and team_ids to a set of recipient emails. Excludes current user."""
194194 emails = set ()
195195
@@ -231,8 +231,8 @@ def _collect_recipient_emails(
231231def _build_typed_records_for_user (
232232 enterprise : enterprise_types .IEnterpriseData ,
233233 email : str ,
234- record_data : list [ dict [str , Any ]],
235- ) -> list [TypedRecord ]:
234+ record_data : List [ Dict [str , Any ]],
235+ ) -> List [TypedRecord ]:
236236 """Substitute template params and convert JSON templates to typed records."""
237237 user_records = []
238238 for template in record_data :
@@ -247,10 +247,10 @@ def _build_typed_records_for_user(
247247def _build_records_add_request (
248248 auth : keeper_auth .KeeperAuth ,
249249 vault : vault_online .VaultOnline ,
250- typed_records : list [TypedRecord ],
250+ typed_records : List [TypedRecord ],
251251 user_ec_key : Any ,
252252 user_rsa_key : Any ,
253- record_keys_out : dict [str , bytes ],
253+ record_keys_out : Dict [str , bytes ],
254254) -> record_pb2 .RecordsAddRequest :
255255 """Build RecordsAddRequest and fill record_keys_out with uid -> encrypted_key for transfer."""
256256 rq = record_pb2 .RecordsAddRequest ()
@@ -303,7 +303,7 @@ def _add_transfer_and_cleanup(
303303 auth : keeper_auth .KeeperAuth ,
304304 email : str ,
305305 add_request : record_pb2 .RecordsAddRequest ,
306- record_keys_for_user : dict [str , Any ],
306+ record_keys_for_user : Dict [str , Any ],
307307) -> None :
308308 """Execute records_add, transfer ownership to user, then unlink from admin (pre_delete + delete)."""
309309 rs = auth .execute_auth_rest (
@@ -378,7 +378,7 @@ def _process_one_recipient(
378378 auth : keeper_auth .KeeperAuth ,
379379 vault : vault_online .VaultOnline ,
380380 email : str ,
381- record_data : list [ dict [str , Any ]],
381+ record_data : List [ Dict [str , Any ]],
382382) -> None :
383383 """Load user key, build records, add to vault, transfer ownership to user."""
384384 user_key = auth .get_user_keys (email )
@@ -428,9 +428,9 @@ def push_enterprise_records(
428428 enterprise : enterprise_types .IEnterpriseData ,
429429 auth : keeper_auth .KeeperAuth ,
430430 vault : vault_online .VaultOnline ,
431- user_ids : list [str ],
432- team_ids : list [str ],
433- record_data : list [ dict [str , Any ]],
431+ user_ids : List [str ],
432+ team_ids : List [str ],
433+ record_data : List [ Dict [str , Any ]],
434434 ) -> None :
435435 """Resolve recipients, then for each user substitute template params and add/transfer records."""
436436 emails = list (
0 commit comments