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_area
to 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/algebra
cannot import from applicationsrc/apps/geometry
and vice versa; they can depend onsrc/apps/utils/
,src/shared/
and certain 3rd party requirements (onlyclick
). src/apps/utils
can only be imported from thesrc/apps
and cannot depend onsrc/shared
.src/shared
cannot 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/unit
cannot 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.py
cannot 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.py
cannot depend ontests/unit/helpers.py
). - Tests in a test suite can depend on
conftest.py
files in the test suite and up in the directory hierarchy (e.g.tests/unit/test_implementation.py
can depend ontests/unit/conftest.py
andtests/conftest.py
, but it cannot depend ontests/integration/conftest.py
).