Comments (6)
First of all, great hook!
The idea behind the hook is to have a single source of truth for all our packages, right?
Thank you! Yes, you are right. That's exactly the reason why this hook exists.
Regarding your question, I can't replicate what you are describing. Here's my test:
starting .pre-commit-config.yaml
minimum_pre_commit_version: 2.15.0
repos:
- repo: https://github.com/floatingpurr/sync_with_poetry
rev: 0.4.0
hooks:
- id: sync_with_poetry
args: [--db, .sync-with-poetry-db.json]
- repo: https://github.com/python-poetry/poetry
rev: b6d4b0adafb45204aadace143f73a789c1c0e33e # sync_with_poetry works!
hooks:
- id: poetry-check
- id: poetry-lock
- id: poetry-export
args: ["-f", "requirements.txt", "-o", "requirements.txt"]
snippet of pyproject.toml
[tool.poetry.dependencies]
python = "^3.10"
[tool.poetry.group.dev.dependencies]
poetry = "^1.2.0"
pre-commit = "^2.20.0"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
Resulting .pre-commit-config.yaml
after sync_with_poetry
minimum_pre_commit_version: 2.15.0
repos:
- repo: https://github.com/floatingpurr/sync_with_poetry
rev: 0.4.0
hooks:
- id: sync_with_poetry
args: [--db, .sync-with-poetry-db.json]
- repo: https://github.com/python-poetry/poetry
rev: 1.2.0 # sync_with_poetry worked!
hooks:
- id: poetry-check
- id: poetry-lock
- id: poetry-export
args: ["-f", "requirements.txt", "-o", "requirements.txt"]
Did you put Poetry in your dev dependencies?
from sync_with_poetry.
Did you put Poetry in your dev dependencies?
Oh, you are right. I was not aware that was possible, it fixes the issue for Poetry.
What about the second part of the question: adding sync_with_poetry
to pyproject.toml as well and allowing self-syncing?
from sync_with_poetry.
I do not understand why you should install sync_with_poetry
as a Python package or CLI in your env, instead of using it just as hook. Can you expand on your use case and setup?
from sync_with_poetry.
I am using sync_with_poetry
as a hook. All hooks are by default CLI tools and except sync_with_poetry
they are all installable. Thus I can put them in my pyproject.toml and control their version there. Currently, I have to maintain only the version of sync_with_poetry
manually or with perhaps pre-commit update; the rest of the hook versions are handled with sync_with_poetry
.
I think it would be nice to have sync_with_poetry
in pyproject.toml as well. This way we do not need to care about the 'rev' field in the .pre-commit-config.yaml at all.
from sync_with_poetry.
Oh, I see. Currently, sync_with_poetry
is not on PyPI. You just need to install from this repo. E.g.,:
$ poetry add git+https://github.com/floatingpurr/sync_with_poetry --group dev
and you'll get in pyproject.toml
the following entry:
sync-with-poetry = {git = "https://github.com/floatingpurr/sync_with_poetry"}
and in poetry.lock
:
[[package]]
name = "sync-with-poetry"
version = "0.4.0"
description = ""
category = "dev"
optional = false
python-versions = "^3.6.1"
develop = false
then you just need to track it in the db file:
{
"sync-with-poetry": {
"repo": "https://github.com/floatingpurr/sync_with_poetry",
"rev": "${rev}"
}
}
and you are all set.
But pay attention! This is not the recommended way to interact with this piece of code. Having a local version of sync_with_poetry
is not necessary and it can mess up your Python dependencies without a valid reason.
Hope this helps.
from sync_with_poetry.
Thanks, that sounds legit.
But pay attention! This is not the recommended way to interact with this piece of code. Having a local version of sync_with_poetry is not necessary and it can mess up your Python dependencies without a valid reason.
I believe since pre-commit maintains its own versions that should be fine.
from sync_with_poetry.
Related Issues (9)
- Alternative solution HOT 3
- Run sync_with_poetry after changing the .pre-commit.config.yaml HOT 11
- [Question] Does this work with plugins? HOT 1
- Allow passing in custom db HOT 1
- FR: Strip `frozen: x.x.x` comments HOT 5
- Poetry 1.5.0 removes category field. HOT 9
- Autoupdate for flake8 does not work HOT 3
- Matching seems to fails when revision has double quotes HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sync_with_poetry.