Skip to content
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

Poetry check virtual environment command for git hooks #9313

Open
maederm opened this issue Apr 17, 2024 · 0 comments
Open

Poetry check virtual environment command for git hooks #9313

maederm opened this issue Apr 17, 2024 · 0 comments
Labels
kind/feature Feature requests/implementations status/triage This issue needs to be triaged

Comments

@maederm
Copy link

maederm commented Apr 17, 2024

Issue Kind

Brand new capability

Description

I'd like to have a poetry check command for the virtual environment that basically does poetry install --sync --dry-run with the following changes:

  • Prints only the summary Package operations: 1 install, 0 updates, 0 removals, 56 skipped
  • Exit 0 if no operations would have been done
  • Exit 1 otherwise

This was requested in #3599 as well but was dropped due to lack of interest.

I can try to create a Pull Request but I'd need some guidance regarding calling the Executor from check command. It's probably easier to implement it in poetry install but it feels wrong from a UX perspective.

Impact

This feature can be used in a pre-commit post-checkout and post-merge hook to notify a developer if their current virtual environment isn't up to date. It saves troubleshooting time when other developers update dependencies and your current venv isn't up to date.

It also doesn't force the developer to use the workaround mentioned below that forces the developer to always scroll again to see the relevant output.

Workarounds

You can use this snippet, but it prints all the dependencies and doesn't exit with a failure reason.

  - repo: https://github.com/python-poetry/poetry
    rev: 1.8.2
    hooks:
    - id: poetry-check
    - id: poetry-install
      args:
      - --dry-run
      - --sync
      verbose: true
      stages:
        - post-checkout
        - post-merge
      always_run: true # needed for post-checkout and post-merge
@maederm maederm added kind/feature Feature requests/implementations status/triage This issue needs to be triaged labels Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Feature requests/implementations status/triage This issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

1 participant