Skip to content

[BUG] Doesn't detect cycles when deep relative imports are used #14

@webknjaz

Description

@webknjaz

I haven't tried to debug it but it's reproducible with this version of my project: https://github.com/sanitizers/octomachinery/tree/4cd3455d6d5f62b94bd1fd2ce78658cbce3eb18a

pycycle says No worries, no cycles here! but in fact it misses some.

This is how it explodes in runtime:

$ ipython
Python 3.8.0 (default, Oct 16 2019, 16:00:06) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.11.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from octomachinery.github.api.app_client import GitHubApp                  
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-1b4597177f26> in <module>
----> 1 from octomachinery.github.api.app_client import GitHubApp

~/.pyenv/versions/chronographer-github-app-py3.8.0-pyenv-venv/lib/python3.8/site-packages/octomachinery/github/api/app_client.py in <module>
     10 
     11 # pylint: disable=relative-beyond-top-level
---> 12 from ...app.routing import WEBHOOK_EVENTS_ROUTER
     13 # pylint: disable=relative-beyond-top-level
     14 from ...app.routing.abc import OctomachineryRouterBase

~/.pyenv/versions/chronographer-github-app-py3.8.0-pyenv-venv/lib/python3.8/site-packages/octomachinery/app/__init__.py in <module>
      1 """GitHub App infra."""
      2 
----> 3 from .server.runner import run  # noqa: F401

~/.pyenv/versions/chronographer-github-app-py3.8.0-pyenv-venv/lib/python3.8/site-packages/octomachinery/app/server/runner.py in <module>
     18 from .config import WebServerConfig
     19 # pylint: disable=relative-beyond-top-level
---> 20 from .machinery import run_forever as run_server_forever
     21 
     22 

~/.pyenv/versions/chronographer-github-app-py3.8.0-pyenv-venv/lib/python3.8/site-packages/octomachinery/app/server/machinery.py in <module>
      9 
     10 # pylint: disable=relative-beyond-top-level
---> 11 from ...github.api.app_client import GitHubApp
     12 # pylint: disable=relative-beyond-top-level
     13 from ...utils.asynctools import auto_cleanup_aio_tasks

ImportError: cannot import name 'GitHubApp' from partially initialized module 'octomachinery.github.api.app_client' (most likely due to a circular import) (~/.pyenv/versions/chronographer-github-app-py3.8.0-pyenv-venv/lib/python3.8/site-packages/octomachinery/github/api/app_client.py)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions