GithubHelp home page GithubHelp logo

phanabani / pycycle Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bndr/pycycle

0.0 0.0 0.0 26 KB

Tool for pinpointing circular imports in Python. Find cyclic imports in any project

License: MIT License

Python 93.39% Makefile 6.61%

pycycle's Introduction

Pycycle: Find and fix circular imports in python projects

https://api.travis-ci.org/bndr/pycycle.svg?branch=master

Pycycle is an experimental project that aims to help python developers fix their circular dependencies problems.

ImportError: Cannot import name X is a python exception that is related to the circular imports, but the exception tells nothing about where or what.

This tool automatically analyzes the imports of your projects, and looks for imports that may cause a circular dependency problem.

https://i.imgur.com/8JeLQxu.gif

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

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


Examples:
    Get the circular imports in current project:
    $ pycycle --here
    Look for circular imports in another project
    $ pycycle --source /home/user/workspace/awesome_project
    Ignore specific directories when looking for circular import
    $ pycycle --source /home/user/workspace/awesome_project --ignore some_dir,some_dir2
    Get verbose output
    $ pycycle --source /home/user/workspace/awesome_project --verbose

Options:
  --verbose        Verbose output.
  --here           Try to find cycles in the current project.
  --source TEXT    Try to find cycles in the path provided.
  --ignore TEXT    Comma separated directories that will be ignored during
                   analysis.
  --encoding TEXT  Change enconding with which the project is read.
  --help           Show this message then exit.
  --version        Show the version and exit.
$ pycycle --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.
$ pycycle --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 pycycle

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.