Skip to content

Commit dc275c4

Browse files
authored
Merge pull request #102 from sdispater/reinstate-solution-providers
Allow the setting of solution providers from the application
2 parents 9d289bf + f6dffa7 commit dc275c4

File tree

4 files changed

+39
-8
lines changed

4 files changed

+39
-8
lines changed

.github/workflows/release.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,13 @@ jobs:
2222
python-version: 3.8
2323
- name: Install and set up Poetry
2424
run: |
25-
curl -fsS -o get-poetry.py https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py
26-
python get-poetry.py --preview -y
25+
curl -fsS -o install-poetry.py https://raw.githubusercontent.com/sdispater/poetry/master/install-poetry.py
26+
python install-poetry.py --preview -y
27+
28+
- name: Update PATH
29+
shell: bash
30+
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
31+
2732
- name: Build distributions
2833
run: |
2934
source $HOME/.poetry/env

.github/workflows/tests.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,18 @@ jobs:
4343
- name: Install Poetry
4444
shell: bash
4545
run: |
46-
curl -fsS -o get-poetry.py https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py
47-
python get-poetry.py --preview -y
48-
echo "$HOME/.poetry/bin" >> $GITHUB_PATH
49-
echo "%USERPROFILE%/.poetry/bin" >> $GITHUB_PATH
46+
curl -fsS -o install-poetry.py https://raw.githubusercontent.com/sdispater/poetry/master/install-poetry.py
47+
python install-poetry.py --preview -y
48+
49+
- name: Update PATH
50+
if: ${{ matrix.os != 'Windows' }}
51+
shell: bash
52+
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
53+
54+
- name: Update Path for Windows
55+
if: ${{ matrix.os == 'Windows' }}
56+
shell: bash
57+
run: echo "$APPDATA\Python\Scripts" >> $GITHUB_PATH
5058

5159
- name: Setup Poetry
5260
shell: bash

cleo/application.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import re
33
import sys
44

5+
from typing import TYPE_CHECKING
56
from typing import Dict
67
from typing import List
78
from typing import Optional
@@ -37,6 +38,12 @@
3738
from .ui.ui import UI
3839

3940

41+
if TYPE_CHECKING:
42+
from crashtest.solution_providers.solution_provider_repository import (
43+
SolutionProviderRepository,
44+
)
45+
46+
4047
class Application:
4148
"""
4249
An Application is the container for a collection of commands.
@@ -70,6 +77,10 @@ def __init__(self, name: str = "console", version: str = "") -> None:
7077

7178
self._command_loader: Optional[CommandLoader] = None
7279

80+
self._solution_provider_repository: Optional[
81+
"SolutionProviderRepository"
82+
] = None
83+
7384
@property
7485
def name(self) -> str:
7586
return self._name
@@ -160,6 +171,11 @@ def catch_exceptions(self, catch_exceptions: bool = True) -> None:
160171
def is_single_command(self) -> bool:
161172
return self._single_command
162173

174+
def set_solution_provider_repository(
175+
self, solution_provider_repository: "SolutionProviderRepository"
176+
) -> None:
177+
self._solution_provider_repository = solution_provider_repository
178+
163179
def add(self, command: Command) -> Optional[Command]:
164180
self._init()
165181

@@ -473,7 +489,9 @@ def create_io(
473489
def render_error(self, error: Exception, io: IO) -> None:
474490
from cleo.ui.exception_trace import ExceptionTrace
475491

476-
trace = ExceptionTrace(error)
492+
trace = ExceptionTrace(
493+
error, solution_provider_repository=self._solution_provider_repository
494+
)
477495
trace.render(io.error_output, isinstance(error, CleoSimpleException))
478496

479497
def _configure_io(self, io: IO) -> None:

cleo/ui/exception_trace.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ def _render_solution(self, io: Union[IO, Output], inspector: Inspector):
316316
inspector.exception
317317
)
318318
symbol = "•"
319-
if not io.output.supports_utf8():
319+
if not io.supports_utf8():
320320
symbol = "*"
321321

322322
for solution in solutions:

0 commit comments

Comments
 (0)