Skip to content

Commit 827ff42

Browse files
committed
[Kubernetes] Accept PEP 585 'dict[K, V]' type strings in pod_config validator
kubernetes client >=36 regenerated its models with PEP 585 style type strings, so map fields like metadata.labels now declare 'dict[str, str]' instead of the old 'dict(str, str)'. The pod_config validator only matched the parenthesized form, so the bracket form fell through to the model-import path and failed with ModuleNotFoundError (No module named 'kubernetes.client.models.dict[str, str]'), breaking sky serve up / launch. Accept both bracket styles.
1 parent 6431739 commit 827ff42

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

sky/provision/kubernetes/utils.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2245,8 +2245,11 @@ def __validate(cls, data, klass):
22452245
sub_kls = match.group(1)
22462246
return [cls.__validate(sub_data, sub_kls) for sub_data in data]
22472247

2248-
if klass.startswith('dict('):
2249-
match = re.match(r'dict\(([^,]*), (.*)\)', klass)
2248+
# kubernetes client <36 emits map types as 'dict(str, V)';
2249+
# >=36 regenerated models use PEP 585 style 'dict[str, V]'.
2250+
# Accept both bracket styles.
2251+
if klass.startswith('dict(') or klass.startswith('dict['):
2252+
match = re.match(r'dict[(\[]([^,]*), (.*)[)\]]', klass)
22502253
if match is None:
22512254
raise ValueError(f'Invalid dict type format: {klass}')
22522255
sub_kls = match.group(2)

0 commit comments

Comments
 (0)