livery.extensions.python._reaches¶
livery.extensions.python._reaches ¶
The private-reaches rule: a source reaching another distribution's privates.
A private is a module or a name with a leading underscore under another
distribution's root, imported (guarded or under TYPE_CHECKING
alike) or read as an attribute of something imported from there. A
test may reach one; a package's source may not, except through the
root contract's [[python.private-reaches]], each entry with its
reason. An entry no source uses any more refuses, so the list only
shrinks. Each distribution's roots are what its build ships, so the
roots one wheel ships are one distribution's.
The rule is a step of the layering phase,
[phases.layering.private-reaches], judged over the one parse of
the python sources (parsed_modules): the files a narrowed run
reaches, every source otherwise.
The scan reads names, not types: a private read through a value
(current()._x) or named in a string (an entry point,
import_module) is not seen.
Functions:
| Name | Description |
|---|---|
private_reaches |
The step: refuse each reach outside the allowance, and each unused entry. |
problems |
Each reach outside the allowance, by its place; each allowance entry unused. |
scan |
Every reach in modules' sources, by distribution and private, to its places. |
allowance |
The root contract's allowed reaches: each distribution and private, to why. |
Attributes:
| Name | Type | Description |
|---|---|---|
ALLOWANCE |
|
private_reaches ¶
private_reaches(ctx: PhaseContext) -> None
The step: refuse each reach outside the allowance, and each unused entry.
The files the run reaches (livery.workshop.selected_files) are judged over the one parse; an unused entry is judged on a run over every source alone.
Source code in packages/extensions/python/src/livery/extensions/python/_reaches.py
problems ¶
problems(modules: tuple[ParsedModule, ...], context: RuleContext) -> list[str]
Each reach outside the allowance, by its place; each allowance entry unused.
An unused entry is judged only when the run reads every source: a narrowed run cannot tell an entry nothing uses from one its scope leaves out.
Source code in packages/extensions/python/src/livery/extensions/python/_reaches.py
scan ¶
scan(modules: tuple[ParsedModule, ...], packages: tuple[Package, ...]) -> dict[tuple[str, str], list[str]]
Every reach in modules' sources, by distribution and private, to its places.
Source code in packages/extensions/python/src/livery/extensions/python/_reaches.py
allowance ¶
The root contract's allowed reaches: each distribution and private, to why.