Fix import resolution for monorepos #645
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes: #564
This PR significantly changes the semantics of
check-external
, and brings a much more explicit understanding of packages to Tach.Before this PR:
source_roots
was defined as a 'project import', or in other words an internal import, and would not be covered bycheck-external
pyproject.toml
was recognized as a package marker, and its parsed contents defined the actual source roots which would be checked (leading to strange behavior when it differed from Tach'ssource_roots
)After this PR:
source_roots
are separate from 'packages', and will 'roll up' to the nearest package above thempyproject.toml
,requirements.txt
,setup.py
or the Tach project root [NOTE:setup.py
is not supported, since it is not always possible to check statically]check-external
will check all imports which resolve to source code outside the current package - this covers local packages in a monorepoThis PR also introduces additional examples and tests. One directory uses namespace packages, while the other is drawn from the docs on
uv workspaces
. In both cases, imports can be resolved to the other local packages, and checked withcheck-external
.Upcoming work:
source_roots
depends_on
equivalents for external dependencies)check-external
into a flag forcheck