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 for auto-relax after poetry add #5

Open
zanieb opened this issue Sep 20, 2022 · 7 comments · May be fixed by #49
Open

Support for auto-relax after poetry add #5

zanieb opened this issue Sep 20, 2022 · 7 comments · May be fixed by #49
Labels
enhancement New feature or request

Comments

@zanieb
Copy link
Owner

zanieb commented Sep 20, 2022

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
Copy link

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
Copy link

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

@zanieb zanieb added the enhancement New feature or request label Mar 19, 2023
@woutervh
Copy link

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
Copy link

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
Copy link
Owner Author

zanieb commented May 24, 2023

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 zanieb linked a pull request Aug 19, 2023 that will close this issue
@zanieb
Copy link
Owner Author

zanieb commented Aug 19, 2023

If people are interested in trying this, I have a draft implementation at #49

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

@adam-grant-hendry
Copy link

adam-grant-hendry commented Aug 25, 2023

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants