fix(page_package): prefer the package found in the working dir - #152
Open
LukasGold wants to merge 2 commits into
Open
fix(page_package): prefer the package found in the working dir#152LukasGold wants to merge 2 commits into
LukasGold wants to merge 2 commits into
Conversation
- add find_first_package_dir, which returns the first search path match - use it for package info lookup instead of searching all paths at once - a package present in working dir and an additional dir no longer raises - closes #135
Contributor
Release previewMerging this PR would release v2.0.3 (current: Changelog preview (truncated)## v2.0.3 (2026-09-01)
### Bug Fixes
- **page_package**: Apply the same search order to package scripts
([`751a0e3`](https://github.com/OpenSemanticLab/osw-python/commit/751a0e3df80000e639349401b29a6ed311fb5f69))
- **page_package**: Prefer the package found in the working dir
([`6e58d9e`](https://github.com/OpenSemanticLab/osw-python/commit/6e58d9ea1fe9067326571356ef8de736c7938ab2))
### Testing
- Rename oold.py to oold_test.py so its tests are collected
([`20072a9`](https://github.com/OpenSemanticLab/osw-python/commit/20072a9249cd97126a222c62a70f84e0433343ef))
Preview via python-semantic-release and conventional commits. |
- the script lookup had the same all-at-once shape as the package lookup - a script present in script_dir and an additional dir no longer raises - cover file matches, not just directory matches
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #135
Changes
find_first_package_dir, which walks the search paths in order and returns the first match, orNonePagePackageController.check_required_pagesuse it: package info dirs and package creation scriptsfind_package_diris untouched, so its all-at-once semantics stay availabletests/test_page_package_search.pycovers search order, fall-through to a later path, no match, file matches as well as directory matches, and thatfind_package_dirstill rejects ambiguityRationale
The old calls passed all search paths to
find_package_dirat once. That function collects matches across every path and raisesValueErrorwhen there is more than one, so a package present both in the working dir and in anadditional_package_dirsentry failed instead of resolving to the local one.The script branch had the same shape and the same latent bug, with
script_dirandadditional_script_dirs. Both are fixed here rather than split across PRs, since it is one bug in two places.Follows the approach proposed in the issue. A path holding several matches on its own is still ambiguous, so it is skipped with a warning rather than guessed at.
Behaviour change worth noting
Previously a lookup that found nothing was swallowed by the broad
except Exceptionand reported as "Error reading package info". Now a missing package and a broken package are two distinct warnings, and a failure to read a package that was found no longer falls through to a lower-priority copy of the same name.