Skip to content

Commit 41fb7fe

Browse files
Fix config validation (#160)
1 parent 17f8699 commit 41fb7fe

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/dipdup/config.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,8 +1070,13 @@ def _validate(self) -> None:
10701070
if name in default_hooks:
10711071
raise ConfigurationError(f'`{name}` hook name is reserved. See docs to learn more about built-in hooks.')
10721072

1073-
# NOTE: Duplicate contracts
1074-
contracts = [cast(ContractIndexConfigT, i).contracts for i in self.indexes.values() if hasattr(i, 'contracts')]
1073+
# NOTE: Detect duplicate contracts
1074+
# FIXME: This code smells
1075+
contracts = [
1076+
cast(ContractIndexConfigT, i).contracts
1077+
for i in self.indexes.values()
1078+
if hasattr(i, 'contracts') and cast(ContractIndexConfigT, i).contracts
1079+
]
10751080
plain_contracts = reduce(operator.add, contracts) if contracts else [] # type: ignore
10761081
# NOTE: After pre_initialize
10771082
duplicate_contracts = [cast(ContractConfig, item).name for item, count in Counter(plain_contracts).items() if count > 1]

0 commit comments

Comments
 (0)