Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
mainred wants to merge 5 commits into master
base: master
Choose a base branch
Loading
from fix-poetry-mismatch

Conversation

Copy link
Collaborator

@mainred mainred commented Sep 26, 2025
edited
Loading

  • fix poetry version mismatch between the precommit check and the one used to create poetry.lock
  • create a poetry makefile target to normalize the poetry version used locally

Copy link
Contributor

coderabbitai bot commented Sep 26, 2025
edited
Loading

Walkthrough

Adds 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

Cohort / File(s) Summary
Git ignore rules
./.gitignore
Adds bin/ to ignored paths.
Build and tooling (Makefile)
./Makefile
Reorganizes sections (Checks, Docs, Dependencies). Adds Poetry bootstrap with version check and auto-install. Introduces deps-install, deps-lock, docs-build, docs-strict, test-llm-ask-holmes (rename from test-llm-investigate), test-without-llm. Routes commands through Poetry.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • Fixing docs to use Poetry #674 — Also switches documentation workflows to Poetry; likely overlaps with this PR’s Makefile docs targets and Poetry-based tooling.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title clearly summarizes the primary change by referencing the poetry version mismatch fix between poetry.lock and the precommit check, which aligns with the Makefile updates and added poetry target in the changeset.
Description Check ✅ Passed The description concisely and accurately describes the main objectives of the changeset by outlining the poetry version mismatch fix and the creation of a Makefile target to normalize poetry, directly reflecting the modifications made.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-poetry-mismatch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 running serve --strict is less CI-friendly than build --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 --strict

Optionally 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); \
 	fi

If 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

📥 Commits

Reviewing files that changed from the base of the PR and between 429dd75 and 7551b86.

📒 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.

@mainred mainred changed the title (削除) Fix poetry mismatch (削除ここまで) (追記) Fix poetry version mismatch between poetry.lock and precommit check (追記ここまで) Sep 26, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between 7551b86 and 7ecbab4.

⛔ 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

Comment on lines +36 to +45
POETRY = $(shell pwd)/bin/poetry
POETRY_VERSION = 1.8.4

.PHONY: poetry
poetry: ## Download poetry locally if necessary.
@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
Copy link
Contributor

@coderabbitai coderabbitai bot Sep 27, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

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.

Copy link
Collaborator Author

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.

coderabbitai[bot] reacted with eyes emoji
Copy link
Contributor

@coderabbitai coderabbitai bot Sep 29, 2025

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:

  1. Poetry installer creates files in POETRY_HOME/bin/ and POETRY_HOME/lib/ - so with POETRY_HOME=$(shell pwd), the binary goes to bin/poetry as you intended
  2. 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.

Copy link
Collaborator Author

mainred commented Sep 29, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@coderabbitai coderabbitai[bot] coderabbitai[bot] left review comments

@moshemorad moshemorad Awaiting requested review from moshemorad

@arikalon1 arikalon1 Awaiting requested review from arikalon1

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

AltStyle によって変換されたページ (->オリジナル) /