All Projects → seddonym → Import Linter

seddonym / Import Linter

Licence: bsd-2-clause
Import Linter allows you to define and enforce rules for the internal and external imports within your Python project.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Import Linter

Linter Js Standard
Atom linter plugin for JavaScript, using JavaScript Standard Style
Stars: ✭ 95 (-9.52%)
Mutual labels:  linter
Rslint
A (WIP) Extremely fast JavaScript and TypeScript linter and Rust crate
Stars: ✭ 1,377 (+1211.43%)
Mutual labels:  linter
Gopherci
GopherCI was a project to help you maintain high-quality Go projects, by checking each GitHub Pull Request, for backward incompatible changes, and a suite of other third party static analysis tools.
Stars: ✭ 105 (+0%)
Mutual labels:  linter
Unimport
A linter, formatter for finding and removing unused import statements.
Stars: ✭ 96 (-8.57%)
Mutual labels:  linter
Eslint Plugin I18n Json
Fully extendable eslint plugin for JSON i18n translation files.
Stars: ✭ 101 (-3.81%)
Mutual labels:  linter
Linter Write Good
An Atom linter interface for write-good.
Stars: ✭ 102 (-2.86%)
Mutual labels:  linter
Lintly
Automated GitHub PR code reviewer for Python, JavaScript, CSS, and more.
Stars: ✭ 91 (-13.33%)
Mutual labels:  linter
Npm Package Json Lint
Configurable linter for package.json files
Stars: ✭ 106 (+0.95%)
Mutual labels:  linter
Tailor
Cross-platform static analyzer and linter for Swift.
Stars: ✭ 1,370 (+1204.76%)
Mutual labels:  linter
Sweep
Reduce the disk usage of your projects by removing dependencies & builds
Stars: ✭ 105 (+0%)
Mutual labels:  dependencies
Graphql Go Tools
Tools to write high performance GraphQL applications using Go/Golang.
Stars: ✭ 96 (-8.57%)
Mutual labels:  linter
Linter Farch
Make sure the filenames stay the same, control them! 👁
Stars: ✭ 101 (-3.81%)
Mutual labels:  linter
Luacheck
A tool for linting and static analysis of Lua code.
Stars: ✭ 1,382 (+1216.19%)
Mutual labels:  linter
Pre Commit Hooks
A set of useful (and documented!) git pre-commit hooks.
Stars: ✭ 95 (-9.52%)
Mutual labels:  linter
Doc8
Style checker for sphinx (or other) rst documentation.
Stars: ✭ 105 (+0%)
Mutual labels:  linter
Libreselery
Continuous distribution of funding to your project contributors and dependencies. Integrated into GitHub Actions
Stars: ✭ 92 (-12.38%)
Mutual labels:  dependencies
Ruby detective
🔎 Investigating your ruby code dependencies
Stars: ✭ 102 (-2.86%)
Mutual labels:  dependencies
Swiftdi
SwiftDI the new way to use your dependency in Swift 5.1
Stars: ✭ 107 (+1.9%)
Mutual labels:  linter
Wemake Python Styleguide
The strictest and most opinionated python linter ever!
Stars: ✭ 1,714 (+1532.38%)
Mutual labels:  linter
Svlint
SystemVerilog linter
Stars: ✭ 103 (-1.9%)
Mutual labels:  linter

============= Import Linter

.. image:: https://img.shields.io/pypi/v/import-linter.svg :target: https://pypi.org/project/import-linter

.. image:: https://img.shields.io/pypi/pyversions/import-linter.svg :alt: Python versions :target: https://pypi.org/project/import-linter/

.. image:: https://api.travis-ci.com/seddonym/import-linter.svg?branch=master :target: https://travis-ci.com/seddonym/import-linter

Import Linter allows you to define and enforce rules for the imports within and between Python packages.

Overview

Import Linter is a command line tool to check that you are following a self-imposed architecture within your Python project. It does this by analysing the imports between all the modules in one or more Python packages, and compares this against a set of rules that you provide in a configuration file.

The configuration file contains one or more 'contracts'. Each contract has a specific type, which determines the sort of rules it will apply. For example, the forbidden contract type allows you to check that certain modules or packages are not imported by parts of your project.

Import Linter is particularly useful if you are working on a complex codebase within a team, when you want to enforce a particular architectural style. In this case you can add Import Linter to your deployment pipeline, so that any code that does not follow the architecture will fail tests.

If there isn't a built in contract type that fits your desired architecture, you can define a custom one.

Quick start

Install Import Linter::

pip install import-linter

Decide on the dependency flows you wish to check. In this example, we have decided to make sure that myproject.foo has dependencies on neither myproject.bar nor myproject.baz, so we will use the forbidden contract type.

Create an .importlinter file in the root of your project to define your contract(s). In this case:

.. code-block:: ini

[importlinter]
root_package = myproject

[importlinter:contract:1]
name=Foo doesn't import bar or baz
type=forbidden
source_modules=
    myproject.foo
forbidden_modules=
    myproject.bar
    myproject.baz

Now, from your project root, run::

lint-imports

If your code violates the contract, you will see an error message something like this:

.. code-block:: text

=============
Import Linter
=============

---------
Contracts
---------

Analyzed 23 files, 44 dependencies.
-----------------------------------

Foo doesn't import bar or baz BROKEN

Contracts: 1 broken.


----------------
Broken contracts
----------------

Foo doesn't import bar or baz
-----------------------------

myproject.foo is not allowed to import myproject.bar:

-   myproject.foo.blue -> myproject.utils.red (l.16)
    myproject.utils.red -> myproject.utils.green (l.1)
    myproject.utils.green -> myproject.bar.yellow (l.3)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].