Giter Club home page Giter Club logo

Comments (6)

floatingpurr avatar floatingpurr commented on May 28, 2024

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.

Berk-Tosun avatar Berk-Tosun commented on May 28, 2024

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.

floatingpurr avatar floatingpurr commented on May 28, 2024

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.

Berk-Tosun avatar Berk-Tosun commented on May 28, 2024

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.

floatingpurr avatar floatingpurr commented on May 28, 2024

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.

Berk-Tosun avatar Berk-Tosun commented on May 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.