8000 Require Pytest 7+ by dmtucker · Pull Request #171 · realpython/pytest-mypy · GitHub
[go: up one dir, main page]

Skip to content

Require Pytest 7+ #171

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

Merged
merged 7 commits into from
Aug 11, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Remove os dep
  • Loading branch information
dmtucker committed Aug 11, 2024
commit 0ac85af3a3c6ac7facaa289349f856757147cdf3
8 changes: 4 additions & 4 deletions src/pytest_mypy.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Mypy static type checker plugin for Pytest"""

import json
import os
from pathlib import Path
from tempfile import NamedTemporaryFile
from typing import Dict, List, Optional, TextIO
Expand Down Expand Up @@ -232,16 +231,17 @@ def from_mypy(
str(path.absolute()): [] for path in paths
} # type: MypyResults._abspath_errors_type

cwd = Path.cwd()
stdout, stderr, status = mypy.api.run(
opts + [os.path.relpath(key) for key in abspath_errors.keys()]
opts + [str(Path(key).relative_to(cwd)) for key in abspath_errors.keys()]
)

unmatched_lines = []
for line in stdout.split("\n"):
if not line:
continue
path, _, error = line.partition(":")
abspath = os.path.abspath(path)
abspath = str(Path(path).absolute())
try:
abspath_errors[abspath].append(error)
except KeyError:
Expand Down Expand Up @@ -310,4 +310,4 @@ def pytest_terminal_summary(terminalreporter, config):
terminalreporter.write_line(results.unmatched_stdout, **color)
if results.stderr:
terminalreporter.write_line(results.stderr, yellow=True)
os.remove(config._mypy_results_path)
Path(config._mypy_results_path).unlink()
Loading
0