Skip to main content

Find and repair your import cycles in any project

Project description

https://img.shields.io/pypi/v/picycle.svg https://img.shields.io/pypi/l/picycle.svg https://img.shields.io/pypi/wheel/picycle.svg https://img.shields.io/pypi/pyversions/pipenv.svg https://travis-ci.org/bndr/picycle.svg?branch=master

picycle is an experimental project that aims to help developers fix their circular dependencies problems. ImportError: Cannot import name X is a python exception that is related to the circular imports, but it’s not clear from the start. This tool automatically analyzes the imports of your projects, and looks for imports that may cause a circular dependency problem.

Features

  • Shows you the whole chain of the circular imports.

  • Gives you lines of code where each import is, for you to easily find and fix the problem.

  • Visualizes your imports in a graph (Not Yet Implemented)

Usage

$ picycle
Usage: picycle [OPTIONS] COMMAND [ARGS]...


Examples:
    Get the circular imports in current project:
    $ picycle --here
    Look for circular imports in another project
    $ picycle --source /home/user/workspace/awesome_project

Options:
  --verbose      Verbose output.
  --here         Try to find cycles in the current project
  --source TEXT  Try to find cycles in the path provided
  --help         Show this message then exit.
  --version      Show the version and exit.
$ picycle --here
Project successfully transformed to AST, checking imports for cycles..
Cycle Found :(
a_module.a_file: Line 1 -> a_module.b_module.b_file: Line 1 -> c_module.c_file: Line 1 -> d_module.d_file: Line 1 =>> a_module.a_file
Finished.
$ picycle --source /Users/vkravcenko/workspace/awesome_project
Target source provided:/Users/vkravcenko/workspace/awesome_project
Project successfully transformed to AST, checking imports for cycles..
No worries, no cycles here!
If you think some cycle was missed, please open an Issue on Github.
Finished.

Installation

$ pip install picycle

Project details


Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page