a pylint plugin to enforce restrictions on imports within your project, similar to nx's enforce-module-boundaries eslint plugin
Project description
pylint module boundaries
a pylint plugin to enforce boundaries between modules in your project. similar to nx's enforce-module-boundaries eslint plugin
example
say you have three packages in your project - common
, package1
, and package2
- you can use the banned-imports
rule to prevent common
from importing anything from package1
or package2
, thus avoiding issues such as circular dependencies.
Pylint can then be used to detect any violations of this rule:
see usage below for a config example
installing
poetry install pylint-module-boundaries
usage
pyproject.toml
example
[tool.pylint.MASTER]
load-plugins = "pylint_module_boundaries"
banned-imports = '''
{
"common(\\..*)?": ["package1(\\..*)?", "package2(\\..*)?"],
"scripts(\\..*)?": ["package1(\\..*)?", "package2(\\..*)?"]
}
'''
banned-imports-check-usages = true
options
option | type | description | default |
---|---|---|---|
banned-imports |
string |
a JSON object pairing regexes matching modules to arrays of regexes matching modules that they are not allowed to import from. due to the limitations in config types allowed by pylint, this has to be a JSON object represented as a string. note that these regexes must be a full match, so to match any submodules you should append (\\..*)? to the regex (double \ required because it's JSON).yes, i know this option is quite annoying to use but its purpose is to be as flexible as possible. i plan to add an easier to use option in the future that covers most basic use cases. see this issue |
{} |
banned-imports-check-usages |
boolean |
whether usages of the imports should be checked as well as the imports themselves. works on imports of entire modules but can potentially cause false positives depending on your use case | true |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pylint_module_boundaries-1.3.1.tar.gz
.
File metadata
- Download URL: pylint_module_boundaries-1.3.1.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.2 CPython/3.11.5 Linux/6.2.0-1012-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 884f22a4382a0e79aa4afd8e0b424a133dd4f2ab1a727426bb15d96482672c31 |
|
MD5 | da78e11fffb69ae5fe26a6732649091f |
|
BLAKE2b-256 | e4e41d8ecebff03b6e241144333f497936d7cdffa07319ce8cdc4a20b7a05884 |
File details
Details for the file pylint_module_boundaries-1.3.1-py3-none-any.whl
.
File metadata
- Download URL: pylint_module_boundaries-1.3.1-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.2 CPython/3.11.5 Linux/6.2.0-1012-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 407fc9c1555ef65b6743ef99552fb7f5e27574867ddd2fdf848e2592960b7489 |
|
MD5 | 6d7d0fad4da79b30a4a01e10312255c0 |
|
BLAKE2b-256 | 0b708f6aa0477639bfb03d5d5eb830d1a3bf2e13978c9030f5d2d091af40877b |