Skip to content

Add dependency safeguards: deptry, pre-commit, declare pandas#492

Open
turbomam wants to merge 1 commit intomasterfrom
add-dependency-safeguards
Open

Add dependency safeguards: deptry, pre-commit, declare pandas#492
turbomam wants to merge 1 commit intomasterfrom
add-dependency-safeguards

Conversation

@turbomam
Copy link
Collaborator

@turbomam turbomam commented Mar 6, 2026

Summary

  • Declare pandas explicitly in pyproject.toml — used directly by the metatraits transform but was only resolved transitively through pyobo/kgx
  • Add deptry to dev dependencies to catch undeclared imports and stale deps
  • Add .pre-commit-config.yaml wiring up ruff, codespell, and deptry (all three were configured in pyproject.toml but not enforced via hooks)
  • Add [tool.deptry] config excluding notebooks and docs dirs

Context

Found while reviewing the poetry.lock diff in #490 — 7K lines changed with only 1 declared new dep. Opened as #491.

Note: GitHub reports 33 known vulnerabilities on the default branch. Adding pip-audit or safety as a follow-up would help catch these in CI.

Closes #491

Test plan

  • poetry install resolves cleanly with the new pandas declaration
  • pre-commit run --all-files passes (or surfaces known issues to fix)
  • deptry . reports no undeclared transitive imports

🤖 Generated with Claude Code

- Declare pandas explicitly in pyproject.toml (used directly by
  metatraits transform, was only resolved transitively via pyobo/kgx)
- Add deptry to dev dependencies for catching undeclared imports
- Add .pre-commit-config.yaml wiring up ruff, codespell, and deptry
- Add [tool.deptry] config excluding notebooks and docs dirs

Closes #491

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 6, 2026 18:50
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds explicit dependency and developer tooling safeguards to prevent undeclared/transitive dependency breakage and to enforce repo hygiene via pre-commit.

Changes:

  • Declare pandas as a direct runtime dependency.
  • Add deptry to dev dependencies and configure it to exclude notebooks/ and docs/.
  • Introduce .pre-commit-config.yaml to run ruff, codespell, and deptry via hooks.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
pyproject.toml Adds pandas and deptry, plus deptry config exclusions.
.pre-commit-config.yaml Wires ruff, codespell, and deptry into pre-commit.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +7 to +8
- id: ruff-format

Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

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

This introduces ruff-format in pre-commit, but the repo’s existing formatting workflow uses black (see tox.ini testenv:format). Unless the project is intentionally migrating away from Black, this will lead to inconsistent formatting between pre-commit and tox -e format/developer workflows; consider either adding a Black pre-commit hook or updating tox/config to use Ruff formatter consistently (and align line-length settings).

Suggested change
- id: ruff-format
- repo: https://github.com/psf/black
rev: 24.4.2
hooks:
- id: black

Copilot uses AI. Check for mistakes.
- tomli

- repo: https://github.com/fpgmaas/deptry
rev: 0.23.0
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

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

The pre-commit hooks pin specific tool versions (ruff-pre-commit rev and deptry rev), but pyproject.toml allows much older versions (e.g., ruff = ">=0.2.1", deptry = ">=0.16.0"). This can cause confusing drift where poetry run ruff/deptry behaves differently from pre-commit; consider pinning the Poetry dev dependency versions to match the hook revs (or vice versa) to keep results consistent.

Suggested change
rev: 0.23.0
rev: 0.16.0

Copilot uses AI. Check for mistakes.
Comment on lines 27 to +39
@@ -35,6 +36,7 @@ jupyter-contrib-nbextensions = "^0.7.0"
python-sql = "^1.4.2"
ipython-sql = "^0.5.0"
ruff = ">=0.2.1"
deptry = ">=0.16.0"
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

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

pandas and deptry are added/updated in pyproject.toml, but this PR doesn’t update poetry.lock. With a committed lockfile, poetry install (including CI) will fail with a "pyproject.toml changed significantly" error until the lock is regenerated and committed (e.g., poetry lock / poetry update pandas deptry).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add dependency safeguards (deptry, undeclared transitive deps)

2 participants