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

Pre-commit hook for check and lock not working in subdirectories. #7247

Closed
4 tasks done
gnkow opened this issue Dec 24, 2022 · 4 comments
Closed
4 tasks done

Pre-commit hook for check and lock not working in subdirectories. #7247

gnkow opened this issue Dec 24, 2022 · 4 comments
Labels
status/duplicate Duplicate issues

Comments

@gnkow
Copy link

gnkow commented Dec 24, 2022

  • I am on the latest stable Poetry version, installed using a recommended method.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I have consulted the FAQ and blog for any relevant entries or release notes.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option) and have included the output below.

Issue

I've a multi-root project directory such as:

/api (poetry/python)
     /pyproject.toml
/api2 (non-python)
.pre-commit-config.yml

My .pre-commit-config.yml states:

repos:
  - repo: https://github.com/python-poetry/poetry
    rev: 1.3.1
    hooks:
      - id: poetry-check
      - id: poetry-lock

Whenever I try to use the pre-commit hook I get this:

poetry-check.........................................(no files to check)Skipped
poetry-lock..............................................................Failed
- hook id: poetry-lock
- exit code: 1

Poetry could not find a pyproject.toml file in <ROOT> or its parents

Is there a way to run the pre-commit from the api folder?

@gnkow gnkow added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Dec 24, 2022
@gnkow
Copy link
Author

gnkow commented Dec 24, 2022

Closing due to duplicate #7239

@gnkow gnkow closed this as completed Dec 24, 2022
@neersighted neersighted added status/duplicate Duplicate issues and removed kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Dec 24, 2022
@neersighted neersighted closed this as not planned Won't fix, can't repro, duplicate, stale Dec 24, 2022
@rubenvdg
Copy link

rubenvdg commented Dec 30, 2022

Actually, this issue rightfully mentions that the poetry-lock hook doesn't work if your poetry project is not in the root of your repo and #7239 does not mention that (it only mentions poetry-check).

Therefore, I think this is not a duplicate (but a superset of #7239).

Maybe it'd be good to re-open?

UPDATE: probably the same holds for poetry-export.

@xinbinhuang
Copy link

xinbinhuang commented Jan 4, 2023

@rubenvdg @gnkow
I believe they're different issue. While #7239 is about poetry command itself, this one is more about the hook configuration. The problem is that the current the .pre-commit-config.yaml hardcoded the files: ^poetry.lock$, which means that it'll only trigger the hook when the files are in the root directory. I created a PR to fix it: #7247 .

Before it's merged and released, you can adjust your hook config with the same changes in the PR, and that should fix it.

Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status/duplicate Duplicate issues
Projects
None yet
Development

No branches or pull requests

4 participants