This is a toy repository containing a few visibility rules
that should help you to get started writing own rules.
You can amend the pants-plugins/macros.py rules or modify the Python source code and see what kind of
violations your changes trigger. For instance, adding
from src.apps.geometry.implementation import calculate_rectangle_areato src/apps/algebra/main.py would trigger the following violation:
DependencyRuleActionDeniedError: src/apps/algebra/main.py has 1 dependency violation:
* src/apps/algebra/BUILD[!*] -> src/apps/geometry/BUILD[!*] : DENY
python_sources src/apps/algebra/main.py -> python_sources src/apps/geometry/implementation.py
because an application is not allowed to import from another application.
There's a branch named dependency-violations containing multiple violations that you can check out to learn more.
Run pants lint :: to validate dependencies.
- Application
src/apps/algebracannot import from applicationsrc/apps/geometryand vice versa; they can depend onsrc/apps/utils/,src/shared/and certain 3rd party requirements (onlyclick). src/apps/utilscan only be imported from thesrc/appsand cannot depend onsrc/shared.src/sharedcannot depend on anything other than the code within thesrc/shared.
- Tests in a test suite cannot depend on non-code resources from another test suite (e.g.
tests/unitcannot depend on files fromtests/integration). - Tests in a test suite cannot depend on code in test modules from another test suite (e.g.
tests/unit/test_implementation.pycannot depend on code fromtests/integration/test_implementation.py). - Helpers modules in a test suite can only depend on source code in the same suite and cannot depend on sources
from another test suite (e.g.
tests/integration/helpers.pycannot depend ontests/unit/helpers.py). - Tests in a test suite can depend on
conftest.pyfiles in the test suite and up in the directory hierarchy (e.g.tests/unit/test_implementation.pycan depend ontests/unit/conftest.pyandtests/conftest.py, but it cannot depend ontests/integration/conftest.py).