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 |
Metadata
Release files for pylint-module-boundaries 1.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pylint_module_boundaries-1.3.1.tar.gz | 4.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pylint_module_boundaries-1.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.5 kB
Release files / pylint_module_boundaries-1.3.1.tar.gz
| Download URL | pylint_module_boundaries-1.3.1.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
884f22a4382a0e79aa4afd8e0b424a133dd4f2ab1a727426bb15d96482672c31
|
|
BLAKE2b-256 checksum How to use checksums |
e4e41d8ecebff03b6e241144333f497936d7cdffa07319ce8cdc4a20b7a05884
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.2 CPython/3.11.5 Linux/6.2.0-1012-azure
|
Release files / pylint_module_boundaries-1.3.1-py3-none-any.whl
| Download URL | pylint_module_boundaries-1.3.1-py3-none-any.whl |
|---|---|
| Size | 3.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
407fc9c1555ef65b6743ef99552fb7f5e27574867ddd2fdf848e2592960b7489
|
|
BLAKE2b-256 checksum How to use checksums |
0b708f6aa0477639bfb03d5d5eb830d1a3bf2e13978c9030f5d2d091af40877b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.2 CPython/3.11.5 Linux/6.2.0-1012-azure
|