Skip to content

Commit

Permalink
Merge pull request #4332 from python-poetry/reinstate-solution-providers
Browse files Browse the repository at this point in the history
Bring back error solutions
  • Loading branch information
sdispater committed Jul 30, 2021
2 parents 3a1b45f + bbff6e8 commit df77c80
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
8 changes: 4 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions poetry/console/application.py
Expand Up @@ -26,6 +26,12 @@
from .commands.command import Command


if TYPE_CHECKING:
from crashtest.solution_providers.solution_provider_repository import (
SolutionProviderRepository,
)


def load_command(name: str) -> Callable:
def _load() -> Type[Command]:
module = import_module(
Expand Down Expand Up @@ -159,6 +165,13 @@ def create_io(

return io

def render_error(self, error: Exception, io: IO) -> None:
# We set the solution provider repository here to load providers
# only when an error occurs
self.set_solution_provider_repository(self._get_solution_provider_repository())

super().render_error(error, io)

def _run(self, io: IO) -> int:
self._disable_plugins = io.input.parameter_option("--no-plugins")

Expand Down Expand Up @@ -330,6 +343,20 @@ def _default_definition(self) -> "Definition":

return definition

def _get_solution_provider_repository(self) -> "SolutionProviderRepository":
from crashtest.solution_providers.solution_provider_repository import (
SolutionProviderRepository,
)

from poetry.mixology.solutions.providers.python_requirement_solution_provider import (
PythonRequirementSolutionProvider,
)

repository = SolutionProviderRepository()
repository.register_solution_providers([PythonRequirementSolutionProvider])

return repository


def main() -> int:
return Application().run()
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Expand Up @@ -32,7 +32,7 @@ generate-setup-file = false
python = "^3.6"

poetry-core = { git = "https://github.com/python-poetry/poetry-core.git", branch = "master" }
cleo = "^1.0.0a1"
cleo = "^1.0.0a4"
crashtest = "^0.3.0"
requests = "^2.18"
cachy = "^0.3.0"
Expand Down

0 comments on commit df77c80

Please sign in to comment.