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

when adding dependencies, insert them at the correct ordering index in the list #4383

Open
2 tasks done
rafalkrupinski opened this issue Aug 13, 2021 · 1 comment
Open
2 tasks done
Labels
kind/feature Feature requests/implementations status/triage This issue needs to be triaged

Comments

@rafalkrupinski
Copy link

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

Feature Request

As a python dev team member I'd like to avoid a merge conflict when two users add a different dependency to the project.
Currently all are appended to the end of the dependency list. This causes merge conflict when merging two branches with different dependencies added.
A simple solution to minimize this, is to keep the dependency list ordered alphabetically.

Ideally all new projects would use sorted lists by default, but runtime overhead and existing unordered dependency lists should be considered.

  • Add new configuration option: dependencies.sort = false
  • If the above option is true, change poetry add behaviour to sort all dependency lists by pretty_name and use binary search to insert the new dependencies.

Let me know if this is acceptable and I'll start working on a PR.

@rafalkrupinski rafalkrupinski added kind/feature Feature requests/implementations status/triage This issue needs to be triaged labels Aug 13, 2021
@jason-curtis
Copy link

#3996 got hung up on a couple of items and the contributor gave up. Can we resolve those?

Issue 1: dealing with preexisting comments and preexisting unsorted dep lists

To work around that, maybe we should just have poetry insert lines into a sorted list at the top of [tool.poetry.*.dependencies] and leave any manually curated deps (or deps with comments) at the bottom?

We could also just keep all comments attached to the line below them (as I think @andrei-shabanski was suggesting), but as @br3ndonland mentioned, that might do bad things when comments are used for grouping deps. Personally I think that's fine as poetry already has a system for grouping deps.

Issue 2: configuring it to turn it on/off

@rafalkrupinski has a suggestion above that has dependencies.sort default to false. I'd be happy to have the default be true and put this in a minor release.
@radoering also asked for inclusion in poetry init, which sounds like a good plan to me.
@abn had opinions so CCing them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.

2 participants