Skip to content

Commit e657d93

Browse files
committed
Refactor source spec parsing
1 parent 4f3e653 commit e657d93

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/azul/indexer/__init__.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -425,10 +425,13 @@ def parse(cls, spec: str) -> Self:
425425

426426
@classmethod
427427
def _parse(cls, spec: str) -> tuple[str, Prefix | None]:
428-
rest, sep, prefix = spec.rpartition(':')
429-
assert sep != '', R('Invalid source specification', spec)
430-
prefix = Prefix.parse(prefix) if prefix else None
431-
return rest, prefix
428+
try:
429+
rest, prefix = spec.rsplit(':', 1)
430+
except ValueError:
431+
assert False, R('Invalid source specification', spec)
432+
else:
433+
parsed_prefix = Prefix.parse(prefix) if prefix else None
434+
return rest, parsed_prefix
432435

433436
@property
434437
def _prefix_str(self) -> str:

0 commit comments

Comments
 (0)