-
Notifications
You must be signed in to change notification settings - Fork 181
Fix poetry version mismatch between poetry.lock and precommit check #1003
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughAdds bin/ to .gitignore and significantly refactors the Makefile: introduces Poetry bootstrap logic, new dependency management targets, reorganized check/docs/test sections, and new/renamed targets for LLM tests and docs building. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Dev as Developer
participant Make as Makefile
participant Sh as Shell
participant Py as Poetry Installer
participant Cmd as Target Command
Dev->>Make: make <target>
Make->>Sh: check POETRY presence and version
alt Poetry missing or mismatched
Sh-->>Make: not found / version mismatch
Make->>Py: install/upgrade Poetry
Py-->>Make: Poetry ready
else Poetry OK
Sh-->>Make: version OK
end
Make->>Cmd: run target via Poetry (e.g., deps/docs/tests)
Cmd-->>Dev: exit status and output
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (6)
.gitignore (1)
4-4
: Anchor ignore to repository root to avoid overmatching.
bin/
without a leading slash ignores any nested bin/ directory. If the intent is only the top-level Poetry bin, prefer/bin/
.Apply this diff:
-bin/ +/bin/CONTRIBUTING.md (1)
11-11
: Resolve tooling policy mismatch (docs vs Makefile).Docs say "poetry 1.8.5 & up" but Makefile enforces exactly 1.8.5. Pick one:
- Option A (simpler): require exactly 1.8.5 in docs.
- Option B: relax Makefile check to accept >= 1.8.5.
Given this PR’s goal, Option A is likely intended. Suggested doc tweak:
- - poetry `1.8.5` & up + - poetry `1.8.5`Makefile (4)
3-6
: Ensure dev deps are installed before running hooks.Local mypy hook uses
poetry run mypy .
; running pre-commit without ensuring deps are installed can fail on fresh clones.Apply this diff to make check depend on deps-install:
-##@ Checks -check: poetry +##@ Checks +check: poetry deps-install ${POETRY} run pre-commit run -a
16-25
: Use build for strict docs CI, keep serve for local.
docs-strict
runningserve --strict
is less CI-friendly thanbuild --strict
.Apply this diff:
-docs-strict: poetry - ${POETRY} run mkdocs serve --dev-addr=127.0.0.1:7000 --strict +docs-strict: poetry + ${POETRY} run mkdocs build --strictOptionally add a separate target (nice-to-have):
docs-serve-strict: poetry ${POETRY} run mkdocs serve --dev-addr=127.0.0.1:7000 --strict
36-44
: Minor robustness: prefer CURDIR and add common phony/aggregator targets.
- Use Make’s built-in
$(CURDIR)
instead of$(shell pwd)
.- Add
.PHONY
for new targets and common "all/test/clean" shims (helps checkmake and developer UX).Apply this diff:
-POETRY = $(shell pwd)/bin/poetry +POETRY = $(CURDIR)/bin/poetry POETRY_VERSION = 1.8.5 @@ -.PHONY: poetry +.PHONY: poetry check test test-without-llm test-llm-investigate test-llm-ask-holmes docs docs-build docs-strict deps-install deps-lock +.PHONY: all clean + +all: check + +test: test-without-llm test-llm-ask-holmes + +clean: + rm -rf $(CURDIR)/.venv $(CURDIR)/.mypy_cache $(CURDIR)/.pytest_cache $(CURDIR)/site + poetry: ## Download poetry locally if necessary. - @if [ ! -f $(POETRY) ] || ! $(POETRY) --version | grep -q "$(POETRY_VERSION)"; then \ + @if [ ! -f $(POETRY) ] || ! $(POETRY) --version | grep -q "$(POETRY_VERSION)"; then \ echo "Installing poetry $(POETRY_VERSION)"; \ - curl -sSL https://install.python-poetry.org | POETRY_HOME=$(shell pwd) python3 - --version $(POETRY_VERSION); \ + curl -sSL https://install.python-poetry.org | POETRY_HOME=$(CURDIR) python3 - --version $(POETRY_VERSION); \ fiIf you instead want docs’ "& up" policy, we can relax the version check to ">= 1.8.5" using a semantic compare. I can provide that snippet on request.
28-33
: Lock command safety.Consider
poetry lock --no-update
for deterministic lock refreshes when you only want to re-resolve from pyproject without bumping. If you do want updates, keep as-is.-deps-lock: poetry - ${POETRY} lock +deps-lock: poetry + ${POETRY} lock --no-update
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
.gitignore
(1 hunks).pre-commit-config.yaml
(1 hunks)CONTRIBUTING.md
(1 hunks)Makefile
(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025年06月05日T12:23:27.634Z
Learnt from: nherment
PR: robusta-dev/holmesgpt#436
File: tests/llm/utils/mock_utils.py:240-249
Timestamp: 2025年06月05日T12:23:27.634Z
Learning: The holmesgpt project uses Python >= 3.10 and prefers modern type hint syntax like `list[str]`, `dict[str, int]` over importing equivalent types from the typing module like `List[str]`, `Dict[str, int]`.
Applied to files:
CONTRIBUTING.md
🪛 checkmake (0.2.2)
Makefile
[warning] 39-39: Missing required phony target "all"
(minphony)
[warning] 39-39: Missing required phony target "clean"
(minphony)
[warning] 39-39: Missing required phony target "test"
(minphony)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: llm_evals
- GitHub Check: Pre-commit checks
🔇 Additional comments (1)
.pre-commit-config.yaml (1)
3-3
: Poetry hook version bump looks good.Aligns tooling to 1.8.5 consistently with the PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
poetry.lock
is excluded by!**/*.lock
📒 Files selected for processing (1)
Makefile
(1 hunks)
🧰 Additional context used
🪛 checkmake (0.2.2)
Makefile
[warning] 39-39: Missing required phony target "all"
(minphony)
[warning] 39-39: Missing required phony target "clean"
(minphony)
[warning] 39-39: Missing required phony target "test"
(minphony)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: llm_evals
- GitHub Check: Pre-commit checks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid clobbering the repository when bootstrapping Poetry.
Pointing POETRY_HOME
at $(pwd)
makes the installer unpack Poetry’s tarball straight into the repo root. That drops (and overwrites) files such as pyproject.toml
, poetry.lock
, README.md
, lib/
, etc., so a single make
run can corrupt the project and leave a pile of untracked artifacts. Please isolate Poetry into a dedicated directory (e.g. .poetry/
) and stop deleting VERSION
manually.
-POETRY = $(shell pwd)/bin/poetry -POETRY_VERSION = 1.8.4 +POETRY_HOME := $(CURDIR)/.poetry +POETRY := $(POETRY_HOME)/bin/poetry +POETRY_VERSION := 1.8.4 @@ - @if [ ! -f $(POETRY) ] || ! $(POETRY) --version | grep -q "$(POETRY_VERSION)"; then \ - echo "Installing poetry $(POETRY_VERSION)"; \ - curl -sSL https://install.python-poetry.org | POETRY_HOME=$(shell pwd) python3 - --version $(POETRY_VERSION); \ - rm -f VERSION; \ - fi + @if [ ! -x $(POETRY) ] || ! $(POETRY) --version | grep -q "$(POETRY_VERSION)"; then \ + echo "Installing poetry $(POETRY_VERSION)"; \ + mkdir -p $(POETRY_HOME); \ + curl -sSL https://install.python-poetry.org | POETRY_HOME=$(POETRY_HOME) python3 - --version $(POETRY_VERSION); \ + fi
(Also remember to ignore the new .poetry/
directory.)
🧰 Tools
🪛 checkmake (0.2.2)
[warning] 39-39: Missing required phony target "all"
(minphony)
[warning] 39-39: Missing required phony target "clean"
(minphony)
[warning] 39-39: Missing required phony target "test"
(minphony)
🤖 Prompt for AI Agents
In Makefile around lines 36 to 45, the current bootstrap sets POETRY_HOME to the
repo root which causes the installer to unpack files into the project and then
removes VERSION; change POETRY to point at a dedicated directory (e.g. .poetry
inside the repo) and set POETRY_HOME to that directory so the installer does not
unpack into the repo root, remove the rm -f VERSION line (do not delete project
files), and add .poetry/ to .gitignore so the local Poetry install is isolated
and not committed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can simply use $(shell pwd)/bin/poetry
instead of $(shell pwd)/.poetrybin/poetry
for the path of poetry, and bin is the folder for all other tools
https://install.python-poetry.org ues POETRY_HOME/bin
as the target place to store the poetry binary, and append it to PATH.
The VERSION file is created by https://install.python-poetry.org to manage the version of poetry, which is not necessary for us.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
@mainred, thank you for the clarification! Let me verify the Poetry installer behavior to understand if my concern about file corruption was accurate.
🌐 Web query:
Poetry installer POETRY_HOME behavior what files created where
💡 Result:
Short answer — what the installer does and what POETRY_HOME contains
-
Default location:
- Unix: $HOME/.local (installer puts Poetry’s "bin" under $HOME/.local/bin).
- Windows: %APPDATA%\Python\Scripts. [1]
-
If you set POETRY_HOME, the installer installs under that directory (POETRY_HOME/bin, POETRY_HOME/lib, ...). Example: POETRY_HOME=/etc/poetry → poetry command placed in /etc/poetry/bin. [1][2]
-
Files/directories created (typical layout):
- bin/ — the small launcher/script named poetry (executable you run). The launcher sets up sys.path to load Poetry from the lib folder. [2]
- lib/ — the full poetry package code (Python packages the launcher imports). [2]
- the installer also writes PATH instructions into the user shell startup (e.g. ~/.profile) or prints the PATH line you should add so $POETRY_HOME/bin (or $HOME/.local/bin) is on PATH. In Docker contexts you may need to source that file or explicitly set PATH. [1][3]
-
Uninstall: run the installer again with --uninstall or set POETRY_UNINSTALL=1 when running the installer; it will remove the installed files. [1]
Sources: Poetry installer README and related installer discussion/documentation. [1][2][3]
@mainred, thank you for the explanation! You're absolutely right about the Poetry installer behavior. After checking the documentation, I can see that:
- Poetry installer creates files in
POETRY_HOME/bin/
andPOETRY_HOME/lib/
- so withPOETRY_HOME=$(shell pwd)
, the binary goes tobin/poetry
as you intended - The
VERSION
file cleanup makes sense - it's just installer metadata that you don't need to keep
However, I should note that the installer will also create a lib/
directory in the repository root (alongside bin/
) containing Poetry's Python packages. Since you're intentionally using bin/
for tools, you might want to add lib/
to .gitignore
as well to keep Poetry's internal packages out of version control.
Your approach is valid - using the repository root as POETRY_HOME
with bin/
as your tools directory is a reasonable pattern. My original concern about file corruption was overstated given this intentional design.
The current implementation looks good for your use case! The bin/
directory is already in .gitignore
based on the changes in this PR, which covers the main artifact you care about.
We can leverage this PR to use makefile target as the only source of truth of the version or command for poetry-related commands.
cross-paltform ones might not be possible like building holmesgpt on Windows.
Since the check-in failure has been address. This PR is not urgent now.
Uh oh!
There was an error while loading. Please reload this page.