{"id":13468824,"url":"https://github.com/seddonym/import-linter","last_synced_at":"2025-05-14T00:09:25.063Z","repository":{"id":34357765,"uuid":"167795381","full_name":"seddonym/import-linter","owner":"seddonym","description":"Import Linter allows you to define and enforce rules for the internal and external imports within your Python project.","archived":false,"fork":false,"pushed_at":"2025-04-07T09:07:37.000Z","size":592,"stargazers_count":752,"open_issues_count":58,"forks_count":55,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-13T11:43:38.209Z","etag":null,"topics":["dependencies","imports","linter","python"],"latest_commit_sha":null,"homepage":"https://import-linter.readthedocs.io/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/seddonym.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.rst","contributing":"CONTRIBUTING.rst","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.rst","dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-01-27T10:18:22.000Z","updated_at":"2025-04-10T08:57:11.000Z","dependencies_parsed_at":"2024-02-23T19:26:04.862Z","dependency_job_id":"0d4a45de-e95d-4774-96ba-795c7541f5d3","html_url":"https://github.com/seddonym/import-linter","commit_stats":null,"previous_names":[],"tags_count":37,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seddonym%2Fimport-linter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seddonym%2Fimport-linter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seddonym%2Fimport-linter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seddonym%2Fimport-linter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/seddonym","download_url":"https://codeload.github.com/seddonym/import-linter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254044139,"owners_count":22005085,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dependencies","imports","linter","python"],"created_at":"2024-07-31T15:01:19.843Z","updated_at":"2025-05-14T00:09:20.053Z","avatar_url":"https://github.com/seddonym.png","language":"Python","readme":"=============\nImport Linter\n=============\n\n.. image:: https://img.shields.io/pypi/v/import-linter.svg\n    :target: https://pypi.org/project/import-linter\n\n.. image:: https://img.shields.io/pypi/pyversions/import-linter.svg\n    :alt: Python versions\n    :target: https://pypi.org/project/import-linter/\n\n.. image:: https://github.com/seddonym/import-linter/workflows/CI/badge.svg?branch=master\n     :target: https://github.com/seddonym/import-linter/actions?workflow=CI\n     :alt: CI Status\n\nImport Linter allows you to define and enforce rules for the imports within and between Python packages.\n\n* Free software: BSD license\n* Documentation: https://import-linter.readthedocs.io.\n\nOverview\n--------\n\nImport Linter is a command line tool to check that you are following a self-imposed\narchitecture within your Python project. It does this by analysing the imports between all the modules in one\nor more Python packages, and compares this against a set of rules that you provide in a configuration file.\n\nThe configuration file contains one or more 'contracts'. Each contract has a specific\ntype, which determines the sort of rules it will apply. For example, the ``forbidden``\ncontract type allows you to check that certain modules or packages are not imported by\nparts of your project.\n\nImport Linter is particularly useful if you are working on a complex codebase within a team,\nwhen you want to enforce a particular architectural style. In this case you can add\nImport Linter to your deployment pipeline, so that any code that does not follow\nthe architecture will fail tests.\n\nIf there isn't a built in contract type that fits your desired architecture, you can define\na custom one.\n\nQuick start\n-----------\n\nInstall Import Linter::\n\n    pip install import-linter\n\nDecide on the dependency flows you wish to check. In this example, we have\ndecided to make sure that ``myproject.foo`` has dependencies on neither\n``myproject.bar`` nor ``myproject.baz``, so we will use the ``forbidden`` contract type.\n\nCreate an ``.importlinter`` file in the root of your project to define your contract(s). In this case:\n\n.. code-block:: ini\n\n    [importlinter]\n    root_package = myproject\n\n    [importlinter:contract:1]\n    name=Foo doesn't import bar or baz\n    type=forbidden\n    source_modules=\n        myproject.foo\n    forbidden_modules=\n        myproject.bar\n        myproject.baz\n\nNow, from your project root, run::\n\n    lint-imports\n\nIf your code violates the contract, you will see an error message something like this:\n\n.. code-block:: text\n\n    =============\n    Import Linter\n    =============\n\n    ---------\n    Contracts\n    ---------\n\n    Analyzed 23 files, 44 dependencies.\n    -----------------------------------\n\n    Foo doesn't import bar or baz BROKEN\n\n    Contracts: 1 broken.\n\n\n    ----------------\n    Broken contracts\n    ----------------\n\n    Foo doesn't import bar or baz\n    -----------------------------\n\n    myproject.foo is not allowed to import myproject.bar:\n\n    -   myproject.foo.blue -\u003e myproject.utils.red (l.16)\n        myproject.utils.red -\u003e myproject.utils.green (l.1)\n        myproject.utils.green -\u003e myproject.bar.yellow (l.3)\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseddonym%2Fimport-linter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseddonym%2Fimport-linter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseddonym%2Fimport-linter/lists"}