{"id":37668230,"url":"https://github.com/jrhahn/py_import_check","last_synced_at":"2026-01-16T12:00:53.799Z","repository":{"id":62280062,"uuid":"557713333","full_name":"jrhahn/py_import_check","owner":"jrhahn","description":null,"archived":false,"fork":false,"pushed_at":"2022-11-15T19:23:38.000Z","size":28,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2023-04-29T19:28:22.631Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jrhahn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-10-26T06:56:35.000Z","updated_at":"2022-10-30T07:59:39.000Z","dependencies_parsed_at":"2023-01-23T03:00:14.393Z","dependency_job_id":null,"html_url":"https://github.com/jrhahn/py_import_check","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"purl":"pkg:github/jrhahn/py_import_check","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jrhahn%2Fpy_import_check","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jrhahn%2Fpy_import_check/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jrhahn%2Fpy_import_check/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jrhahn%2Fpy_import_check/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jrhahn","download_url":"https://codeload.github.com/jrhahn/py_import_check/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jrhahn%2Fpy_import_check/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28478399,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T11:59:17.896Z","status":"ssl_error","status_checked_at":"2026-01-16T11:55:55.838Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2026-01-16T12:00:41.582Z","updated_at":"2026-01-16T12:00:53.772Z","avatar_url":"https://github.com/jrhahn.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# *import-check* pre-commit hook\n\n## Description\nThis pre-commit hook allows to prevent importing a Python module by another\nPython module. In a configuration file for each module the list of *forbidden*\nimports can be configured.\n\nThis is especially useful when working with a mono repository where there is only\na single virtual environment across all modules but you want to ensure that\nimporting internal modules follow certain conventions. One such convention could be\nthat certain modules should not imports others to prevent circular dependencies and\nhaving the flexibility to package the modules separately in the future.\n\nAn alternative would be to test each module in its own virtual environment where\nyou have much better control over the packages that should be installed.\nThe downsides of the separate builds are that a) there might be mismatching requirements\nbetween the modules and b) it obviously takes longer to set up isolated environments\nwhich is critical in CI/CD.\n\n## Configuration\nCreate a file named ``.import_check.toml`` in the root of the repository.\nNote: Changing the location or the name of the configuration file is currently not supported.\n\nThe file should contain an entry for each module of your code. The name of a module is\ngiven by the top level name in the folder structure.\nAssuming you have a file structure like this:\n```\n|source\n|- package_1\n   |- code_1.py\n|- package_2\n   |- code_1.py\n   |- code_2.py\n```\nThen ``package_1`` and ``package_2`` would be modules for which you could set up rules.\n\nAn example configuration for the file structure above where we want to make sure that\nno single file inside ``package_2`` imports from ``package_1`` would be:\n```toml\n[package_2]\nforbidden_imports = [ \"package_1\" ]\n```\n\n## Installation\nIn order to execute import-check before committing your code changes, add the following\nlines to the project's ``.pre-commit-config.yaml``:\n```yaml\n-   repo: https://github.com/jrhahn/py_import_check\n    rev: v0.0.1\n    hooks:\n    - id: import-check\n```\nand run ``pre-commit install``.\n\nNote: please make sure to use the latest release. The package releases can\nbe found here: [https://github.com/jrhahn/py_import_check/releases/](https://github.com/jrhahn/py_import_check/releases/)\n\n\n## Update\nTo update the hook, simply run ``pre-commit autoupdate``.\n\n\n## Limitations\n- The configuration file must be located at the project root with the name\n  ``.import_check.toml``\n- Import checks can be configured only for modules at the top level, i.e. there is no support for submodules.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjrhahn%2Fpy_import_check","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjrhahn%2Fpy_import_check","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjrhahn%2Fpy_import_check/lists"}