Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ jobs:
run: |
poetry install

- name: Run typechecking
run: |
poetry run mypy

- name: Run tests
run: |
poetry run pytest -q tests
Expand Down
8 changes: 0 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,3 @@ repos:
hooks:
- id: flake8
additional_dependencies: *flake8_deps

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.982
hooks:
- id: mypy
pass_filenames: false
additional_dependencies:
- pytest>=7.1.2
1,178 changes: 636 additions & 542 deletions poetry.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ classifiers = [
# Requirements
[tool.poetry.dependencies]
python = "^3.7"
crashtest = "^0.4.0"
crashtest = "^0.4.1"
rapidfuzz = "^2.2.0"

[tool.poetry.group.dev.dependencies]
Expand All @@ -37,6 +37,7 @@ pytest-mock = "^3.8.2"
pre-commit = "^2.20.0"
pytest-cov = "^3.0.0"
tox = "^3.25.1"
mypy = "^0.982"

[tool.poetry.group.doc.dependencies]
Sphinx = "^5.2.3"
Expand Down
7 changes: 6 additions & 1 deletion src/cleo/commands/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@


if TYPE_CHECKING:
from typing import Literal
import sys

if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal

from cleo.io.inputs.argument import Argument
from cleo.io.inputs.option import Option
Expand Down
3 changes: 2 additions & 1 deletion src/cleo/ui/exception_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,14 +259,15 @@ def render(self, io: IO | Output, simple: bool = False) -> None:

self._render_solution(io, self._exception)

def _render_exception(self, io: IO | Output, exception: Exception) -> None:
def _render_exception(self, io: IO | Output, exception: BaseException) -> None:
from crashtest.inspector import Inspector

inspector = Inspector(exception)
if not inspector.frames:
return

if inspector.has_previous_exception():
assert inspector.previous_exception is not None # make mypy happy
self._render_exception(io, inspector.previous_exception)
io.write_line("")
io.write_line(
Expand Down
7 changes: 6 additions & 1 deletion src/cleo/ui/table_cell_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@


if TYPE_CHECKING:
from typing import Literal
import sys

if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal

_Align = Union[Literal["left"], Literal["right"]]

Expand Down
3 changes: 1 addition & 2 deletions tests/fixtures/exceptions/solution.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
from crashtest.contracts.provides_solution import ProvidesSolution


# mypy fails here because crashtest is not typed.
class CustomError(ProvidesSolution, Exception): # type: ignore
class CustomError(ProvidesSolution, Exception):
@property
def solution(self) -> BaseSolution:
solution = BaseSolution("Solution Title.", "Solution Description")
Expand Down
24 changes: 12 additions & 12 deletions tests/ui/test_exception_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,13 +288,13 @@ def test_render_supports_solutions() -> None:

Error with solution

at {trace._get_relative_file_path(solution.__file__)}:17 in call
13│ return solution
at {trace._get_relative_file_path(solution.__file__)}:16 in call
12│ return solution
13│
14│
15│
16│ def call() -> None:
→ 17│ raise CustomError("Error with solution")
18│
15│ def call() -> None:
→ 16│ raise CustomError("Error with solution")
17│

• Solution Title: Solution Description
https://example.com,
Expand Down Expand Up @@ -325,13 +325,13 @@ def test_render_falls_back_on_ascii_symbols() -> None:

Error with solution

at {trace._get_relative_file_path(solution.__file__)}:17 in call
13| return solution
at {trace._get_relative_file_path(solution.__file__)}:16 in call
12| return solution
13|
14|
15|
16| def call() -> None:
> 17| raise CustomError("Error with solution")
18|
15| def call() -> None:
> 16| raise CustomError("Error with solution")
17|

* Solution Title: Solution Description
https://example.com,
Expand Down