Skip to main content

ouro is a Python package that checks your code for circular (cyclic) imports.

Project description

Ouro

python ouro license tox pre-commit pypi-version pypi-downloads

Description

OURO (OUROboros) is a Python package that checks your code for circular (cyclic) imports.

Currently, ouro only supports absolute imports

Name Origin

The name "ouro" is derived from the term "ouroboros", a symbol from ancient mythology depicting a snake consuming its own tail, representing the concept of infinity and cyclicality. This name was chosen for its apt metaphorical representation of the package's functionality. Just as the ouroboros symbolizes a cycle, the "ouro" package checks for circular imports in Python. The connection to Python, a language named after a type of snake, further reinforces this symbolic link.

Demo

OURO

Installation

You can install ouro in multiple ways, as follows.

Using PIP

pip install ouro

Using Poetry

poetry add ouro

From Source

  1. Clone this repo

    git clone https://github.com/abdelrahman0w/ouro
    

    Or you can download it as a zip file

  2. Naviage to the repo directory

    cd ouro
    
  3. Once you have a copy of the source, you can install it as follows:

    • Using make

      make install
      
    • Using pip

      pip install .
      
    • Or directly from the setup.py file

      python setup.py install
      

Usage

Using the CLI tool

Basic Usage

  1. Navigage to your project

    cd path/to/your/project
    
  2. Run ouro

    ouro
    

Entry Point

ouro [-h] [-v] [--verbose] [--no-categorize] [-e] [-i IGNORE [IGNORE ...]] [path]

Available Options

<path>             path to the Python project to be checked (default: current working directory)

-h, --help         show this help message and exit
-v, --version      show version number and exit
--verbose          increase output verbosity (print report to console)
--no-categorize    don't categorize cycles (mark all cycles as critical)
-e, --export       export the report to a json file
-i. --ignore       list of files, directories, or glob patterns to ignore

As a pre-commit hook

Check pre-commit for instructions

  • Sample usage in .pre-commit-config.yaml file:

    Add ouro to repos as follows:

    - repo: https://github.com/abdelrahman0w/ouro
        rev: v0.2.0
        hooks:
        - id: ouro
    

Features

Current features are checked

  • CLI tool for checking circular imports in a Python code
  • Get the context of the import to ignore imports within a function scope
  • Ignore .git dir in case of git repo
  • Ignore paths and patterns in .gitignore file
  • Ability to ignore a file name, directory name, or a glob pattern
  • Show imports in context with file name and line number
  • Support for absolute imports
  • Support for relative imports

Changelog

0.2.0 (2024-02-13)

Features

  • Enhance performance by around %60

0.1.3 (2024-01-31)

Fixed

  • add missing instsll requirements

0.1.2 (2024-01-31)

Fixed

  • bug fixes

0.1.1 (2024-01-29)

Fixed

  • pre-commit hook
  • bug in possible origins func

0.1.0 (2024-01-27)

Features

  • CLI tool for checking circular imports in a python package

    Currently, supports absolute imports only

  • Gets the context of the import to ignore imports within a function scope
  • Ignores .git dir in case of git repo
  • Ignores paths in .gitignore file
  • Ability to ignore a file name, directory name, or a glob pattern

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ouro-0.2.0.tar.gz (15.1 kB view hashes)

Uploaded Source

Built Distribution

ouro-0.2.0-py2.py3-none-any.whl (11.5 kB view hashes)

Uploaded Python 2 Python 3

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