@@ -236,8 +236,15 @@ def format_imports(self, package: str) -> Iterator[str]:
236236 yield f'from { package } import { cls } '
237237
238238 def format_arguments (self ) -> Iterator [str ]:
239- for name , cls in self .iter_arguments ():
240- yield f'{ name } : { cls } '
239+ arguments = list (self .iter_arguments ())
240+ i , counter = 0 , Counter (name for name , _ in arguments )
241+
242+ for name , cls in arguments :
243+ if counter [name ] > 1 :
244+ yield f'{ name } _{ i } : { cls } '
245+ i += 1
246+ else :
247+ yield f'{ name } : { cls } '
241248
242249 def locate_arguments (self ) -> Dict [str , Optional [Type ]]:
243250 kwargs : Dict [str , Optional [Type ]] = {}
@@ -251,13 +258,13 @@ class PatternConfig(CodegenMixin, ABC):
251258 @classmethod
252259 def format_storage_import (cls , package : str , module_name : str ) -> Tuple [str , str ]:
253260 storage_cls = f'{ snake_to_pascal (module_name )} Storage'
254- return f'from { package } .types.{ module_name } .storage' , storage_cls
261+ return f'{ package } .types.{ module_name } .storage' , storage_cls
255262
256263 @classmethod
257264 def format_parameter_import (cls , package : str , module_name : str , entrypoint : str ) -> Tuple [str , str ]:
258265 entrypoint = entrypoint .lstrip ('_' )
259266 parameter_cls = f'{ snake_to_pascal (entrypoint )} Parameter'
260- return f'from { package } .types.{ module_name } .parameter.{ pascal_to_snake (entrypoint )} ' , parameter_cls
267+ return f'{ package } .types.{ module_name } .parameter.{ pascal_to_snake (entrypoint )} ' , parameter_cls
261268
262269 @classmethod
263270 def format_origination_argument (cls , module_name : str , optional : bool ) -> Tuple [str , str ]:
@@ -396,7 +403,7 @@ def iter_imports(self, package: str) -> Iterator[Tuple[str, str]]:
396403 return
397404
398405 module_name = self .destination_contract_config .module_name
399- yield 'from dipdup.models' , 'Transaction'
406+ yield 'dipdup.models' , 'Transaction'
400407 yield self .format_parameter_import (package , module_name , self .entrypoint )
401408 yield self .format_storage_import (package , module_name )
402409
@@ -459,7 +466,7 @@ def iter_imports(self, package: str) -> Iterator[Tuple[str, str]]:
459466 module_name = self .originated_contract_config .module_name
460467 else :
461468 raise ConfigurationError ('Origination pattern must have at least one of `source`, `similar_to`, `originated_contract` fields' )
462- yield 'from dipdup.models' , 'Origination'
469+ yield 'dipdup.models' , 'Origination'
463470 yield self .format_storage_import (package , module_name )
464471
465472 def iter_arguments (self ) -> Iterator [Tuple [str , str ]]:
@@ -666,13 +673,13 @@ def __post_init_post_parse__(self):
666673 def format_key_import (cls , package : str , module_name : str , path : str ) -> Tuple [str , str ]:
667674 key_cls = f'{ snake_to_pascal (module_name )} Key'
668675 key_module = f'{ path } _key'
669- return f'from { package } .types.{ module_name } .big_map.{ key_module } ' , key_cls
676+ return f'{ package } .types.{ module_name } .big_map.{ key_module } ' , key_cls
670677
671678 @classmethod
672679 def format_value_import (cls , package : str , module_name : str , path : str ) -> Tuple [str , str ]:
673680 value_cls = f'{ snake_to_pascal (module_name )} Value'
674681 value_module = f'{ path } _value'
675- return f'from { package } .types.{ module_name } .big_map.{ value_module } ' , value_cls
682+ return f'{ package } .types.{ module_name } .big_map.{ value_module } ' , value_cls
676683
677684 @classmethod
678685 def format_big_map_diff_argument (cls , module_name : str ) -> Tuple [str , str ]:
0 commit comments