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

Support pre-commit hooks even if poetry related files are missing #6944

Closed
2 tasks done
mijdavis2 opened this issue Nov 2, 2022 · 6 comments · Fixed by #8204
Closed
2 tasks done

Support pre-commit hooks even if poetry related files are missing #6944

mijdavis2 opened this issue Nov 2, 2022 · 6 comments · Fixed by #8204
Labels
kind/feature Feature requests/implementations status/triage This issue needs to be triaged

Comments

@mijdavis2
Copy link

mijdavis2 commented Nov 2, 2022

  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I have searched the FAQ and general documentation and believe that my question is not already covered.

Feature Request

Pre-commit is excellent for standardizing checks across an organization's repositories. Other pre-commits use conditionals to SKIP checks if they are unnecessary. Poetry's pre-commits, however, will fail if pyproject.toml/poetry.lock dont exist in a repo,

Current behavior

pre-commits for poetry fail if poetry related files are missing

Ideal behavior

pre-commits for poetry SKIP gracefully if poetry related files are missing

But why?

So .pre-commit-config.yaml files can be consistent across all repos for an organization.

@dimbleby
Copy link
Contributor

dimbleby commented Nov 2, 2022

Submit a pull request!

@onerandomusername
Copy link
Contributor

It looks like just poetry-lock is missing a files pattern which is intentional.

However, pre-commit has a very customisable method for enabling hooks, as you can overwrite any property you'd like. If you'd like to only have poetry lock when pyproject.toml or poetry.lock is changed, you can use the following configuration:

  - repo: https://github.com/python-poetry/poetry
    rev: '1.2.2'
    hooks:
      - id: poetry-lock
        files: '^pyproject.toml$|^poetry.lock$'

This will only run poetry-lock on changes to pyproject.toml or poetry.lock

@amrawadk
Copy link

amrawadk commented Nov 8, 2022

It looks like just poetry-lock is missing a files pattern which is intentional.

@onerandomusername quick question: I was browsing the Poetry issues because I recently needed to add the same files argument to poetry-lock and wasn't sure why that wasn't the default behavior. Because that meant that for every commit I did, that hook was evaluated, whether the lock or the toml files changed or not, which isn't efficient given that the lock command takes a couple of seconds at least.

The only changes I see this command making if neither the lock nor the toml files change is when a dependency gets updated, which means that we can unintentionally introduce changes to the lock file. I don't think that's a good default, and I see a similar discussion happening in this issue where it's about only introducing changes when the user explicitly asks for it.

I'd like to propose adding the files line to the poetry-lock hook in this repo. WDYT? 😄

Note: I recognize this is potentially not the same topic for this issue, so happy to create a new one, but this was the most relevant comment I ran across, hence why I wanted to ask 😄

@onerandomusername
Copy link
Contributor

I'm not a maintainer or involved with poetry development, but I agree that files should likely be provided for poetry-lock. I don't think its intuitive how it currently stands, as it doesn't make sense to update everything on every commit IMO.

@amrawadk
Copy link

amrawadk commented Nov 9, 2022

@onerandomusername I understand. Thanks for the feedback never the less 😄 will file a separate bug for this and share it here.

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
kind/feature Feature requests/implementations status/triage This issue needs to be triaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants