Skip to content

Commit

Permalink
fix extracting arg names
Browse files Browse the repository at this point in the history
  • Loading branch information
droserasprout committed Jan 15, 2025
1 parent 2877215 commit 07dae3e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
3 changes: 1 addition & 2 deletions src/dipdup/datasources/_subsquid.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ async def _fetch_worker(self, level: int) -> DatasourceConfigT:
worker_config.http = self._default_http_config

# NOTE: Fail immediately; retries are handled one level up
if worker_config.http:
worker_config.http.retry_count = 0
worker_config.http.retry_count = 0

return worker_config

Expand Down
16 changes: 8 additions & 8 deletions src/dipdup/runtimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@


@cache
def extract_args_name(description: str) -> tuple[str, ...]:
pattern = r'\((.*?)\)|\[(.*?)\]'
match = re.search(pattern, description)
def extract_args_name(docs: list[str]) -> tuple[str, ...]:
docs_str = ''.join(docs).replace('\\n', '').replace('\n', '')

if not match:
raise ValueError('No valid bracket pairs found in the description')
# find the last bracket pair, [] or ()
open_bracket = max(docs_str.rfind('['), docs_str.rfind('('))
close_bracket = max(docs_str.rfind(']'), docs_str.rfind(')'))
slice = docs_str[open_bracket + 1:close_bracket]

args_str = match.group(1) or match.group(2)
return tuple(arg.strip('\\') for arg in args_str.split(', '))
return tuple(arg.strip('\\ ') for arg in slice.split(','))


@cache
Expand Down Expand Up @@ -86,7 +86,7 @@ def get_event_arg_names(event_abi: dict[str, Any]) -> tuple[str, ...]:

# NOTE: Old metadata
if not arg_names:
arg_names = extract_args_name(event_abi['docs'][0])
arg_names = extract_args_name(event_abi['docs'])

return tuple(arg_names)

Expand Down

0 comments on commit 07dae3e

Please sign in to comment.