zanieb / poetry-relax

Poetry plugin to relax version pins
MIT License
26 stars 2 forks source link

Support for auto-relax after `poetry add` #5

Open zanieb opened 1 year ago

zanieb commented 1 year ago

It's unclear if Poetry would disapprove of this as their documentation states that core command behavior should not be changed but a maintainer notes that a plugin may be a good way to change the default behavior in this comment.

It seems as though it would be straight-forward to add a hook after the add command runs that modifies the pyproject.toml using the mechanisms established for the poetry relax command. It's a little redundant to parse the file again, but I doubt the impact on speed will be noticeable.

If added, this would include a configurable toggle and would likely be off my default.

This issue will track requests for this feature. Feel free to add a 👍 or 👎 reaction here. Additional thoughts are welcome.

woutervh commented 1 year ago

poetry's default of capping upperbounds, is a timebomb waiting to explode. relaxed should be the default. I would even monkeypatch poetry-code to enforce that behaviour

woutervh commented 1 year ago

the arguments are well known, but ignored for now: https://iscinumpy.dev/post/bound-version-constraints/

woutervh commented 1 year ago

I would even monkeypatch poetry-code to enforce that behaviour

To clarify: I meant I would monkeypatch this in my local setups. DId not mean that this plugin should do that.

woutervh commented 1 year ago

Support for auto-relax after poetry add

Why after, and not during? This poetry-relax module at the moent could just be a single-line sed-script replace some chars in a file, after you ran "poetry add".

Why the whole machinery of "plugins" and then make zero use of it?

zanieb commented 1 year ago

This poetry-relax module at the moent could just be a single-line sed-script replace some chars in a file, after you ran "poetry add".

To provide some clarity here: Yes, you could use sed to replace some chars in a file. However, this plugin does far more than that. It leverages a lot of Poetry internals to provide a similar experience to using Poetry itself. It adds support for leveraging the Poetry dependency checker to guarantee that modifying the version specifications does not create an unsolvable dependency tree. It includes the ability to update the lock file. It allows the dependencies to be updated with a flag. These are not features that could be done well with sed and are the reason this library exists.

zanieb commented 10 months ago

If people are interested in trying this, I have a draft implementation at https://github.com/zanieb/poetry-relax/pull/49

I need to add test coverage, so expect there to be problems still.

adam-grant-hendry commented 10 months ago

@zanieb Yes, I think this would be a great addition. poetry-plugin-sort is one such plugin that sets a precedence for this. They utilize the exposed cleo events to sort dependencies after poetry init or poetry add are run.

If worried about the loose definition of "changing", poetry-plugin-sort also adds a pyproject.toml configuration variable that you can set to turn on or off sorting after poetry init or poetry add are implemented. I think this would be a wise addition since it would allow users to turn this feature on or off at their discretion.