File tree Expand file tree Collapse file tree 1 file changed +12
-9
lines changed Expand file tree Collapse file tree 1 file changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -104,21 +104,24 @@ def is_model_class(obj: Any) -> bool:
104104
105105def iter_models (package : Optional [str ]) -> Iterator [Tuple [str , Type [Model ]]]:
106106 """Iterate over built-in and project's models"""
107- if package and not package .endswith ('.models' ):
108- package += '.models'
107+ modules = [
108+ ('int_models' , importlib .import_module ('dipdup.models' )),
109+ ]
109110
110- modules = [importlib .import_module ('dipdup.models' )]
111111 if package :
112- modules .append (importlib .import_module (package ))
113-
114- for models_module in modules :
115- for attr in dir (models_module ):
112+ if not package .endswith ('.models' ):
113+ package += '.models'
114+ modules .append (
115+ ('models' , importlib .import_module (package )),
116+ )
117+
118+ for app , module in modules :
119+ for attr in dir (module ):
116120 if attr .startswith ('_' ):
117121 continue
118122
119- attr_value = getattr (models_module , attr )
123+ attr_value = getattr (module , attr )
120124 if is_model_class (attr_value ):
121- app = 'int_models' if attr_value .__name__ == 'dipdup.models' else 'models'
122125 yield app , attr_value
123126
124127
You can’t perform that action at this time.
0 commit comments