Skip to content

Commit c2aeed0

Browse files
authored
Enable mypy (#20)
1 parent 5cfdfdc commit c2aeed0

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

.pre-commit-config.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ repos:
4040
hooks:
4141
- id: ruff
4242
args: [--fix, --exit-non-zero-on-fix]
43+
- repo: https://github.com/pre-commit/mirrors-mypy
44+
rev: v1.6.0
45+
hooks:
46+
- id: mypy
47+
# empty args needed in order to match mypy cli behavior
48+
args: [--strict]
49+
additional_dependencies:
50+
- pytest
4351
- repo: https://github.com/adrienverge/yamllint.git
4452
rev: v1.32.0
4553
hooks:

src/pytest_plus/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import os
44

55
import pytest
6+
from _pytest.terminal import TerminalReporter
67

78

89
def pytest_sessionfinish(session: pytest.Session) -> None:
@@ -13,6 +14,8 @@ def pytest_sessionfinish(session: pytest.Session) -> None:
1314
that functionality is ignored.
1415
"""
1516
terminalreporter = session.config.pluginmanager.get_plugin("terminalreporter")
17+
if not isinstance(terminalreporter, TerminalReporter):
18+
raise TypeError
1619
req_passed = int(os.environ.get("PYTEST_REQPASS", "0"))
1720
if req_passed and not session.config.option.collectonly:
1821
passed = 0
@@ -27,7 +30,7 @@ def pytest_sessionfinish(session: pytest.Session) -> None:
2730
session.exitstatus = 1
2831

2932

30-
@pytest.hookimpl(tryfirst=True)
33+
@pytest.hookimpl(tryfirst=True) # type: ignore[misc,unused-ignore]
3134
def pytest_collection_modifyitems(items: list[pytest.Item]) -> None:
3235
"""Ensure testing fails if tests have duplicate names."""
3336
errors = []

src/pytest_plus/py.typed

Whitespace-only changes.

0 commit comments

Comments
 (0)