linkyndy / remodel

Very simple yet powerful and extensible Object Document Mapper for RethinkDB, written in Python.
MIT License
193 stars 29 forks source link

Circular imports on create_indexes() and create_tables() #38

Closed thedrow closed 8 years ago

thedrow commented 8 years ago

The following code:

from remodel.helpers import create_indexes, create_tables

# Creates all database tables defined by models
create_tables()
# Creates all table indexes based on model relations
create_indexes()

Placed on __init__.py creates a circular import.

tests/unit/test_file_event.py:1: in <module>
    from configuration_managers.events.file import FileEvent
src/configuration_managers/events/__init__.py:6: in <module>
    create_indexes()
.tox/py35-unit/lib/python3.5/site-packages/remodel/helpers.py:29: in create_indexes
    from .registry import model_registry, index_registry
.tox/py35-unit/lib/python3.5/site-packages/remodel/registry.py:4: in <module>
    import remodel.models
.tox/py35-unit/lib/python3.5/site-packages/remodel/models.py:7: in <module>
    from .field_handler import FieldHandlerBase, FieldHandler
.tox/py35-unit/lib/python3.5/site-packages/remodel/field_handler.py:5: in <module>
    from .registry import index_registry
E   ImportError: cannot import name 'index_registry'

Removing the call to any of the functions and the import doesn't resolve this issue. Only removing both.

linkyndy commented 8 years ago

Thank you for creating an issue for this bug. Indeed, the problem got away since I've got no reply from the original poster.

Issue has been fixed and added to remodel v0.4.4.