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

Refactor: move get_locked() from VersionSolver to Provider #6204

Merged

Conversation

radoering
Copy link
Member

This refactoring is motivated by #6131. While the change in #6131 seems to be functionally correct, I don't like it from an architectural point of view (passing a get_locked from VersionSolver to Provider). However, for the fix Provider has to know about locked packages. After careful consideration, I came to the conclusion that it makes more sense, if Provider provides the get_locked method since Provider already has different methods that take a dependency as input and give one ore more packages. Further, it already has knowledge about installed packages so it makes sense to extend that to locked packages.

To put it in a nutshell, the main objective of this PR is to move get_locked() from VersionSolver to Provider. On the way, I noticed some other shortcomings I changed in separate commits.

In case anyone is wondering why the installed and locked fixtures in test_solver can't be used anymore: Since Provider transforms the list of locked packages into a dict, changes to the list of locked packages after creating a Provider instance have no effect. Since changing locked packages after creating the solver/provider is no real use case (was only done in tests), I decided to adapt the tests in favor of a more clear interface that fits better to the real world use case.

@radoering radoering requested a review from a team August 20, 2022 22:08
@radoering radoering force-pushed the refactor-solver-and-provider branch 2 times, most recently from 52e2ca4 to 9f8ed55 Compare August 21, 2022 07:55
…sed in tests and can cause inconsistencies between a solver and its provider)
…lways be set via contextmanager "use_environment" to avoid inconsistent python_constraint)
@neersighted neersighted merged commit 21228d1 into python-poetry:master Aug 31, 2022
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants