Skip to content

Commit

Permalink
Remove os dep
Browse files Browse the repository at this point in the history
  • Loading branch information
dmtucker committed Aug 11, 2024
1 parent 7acfaeb commit 0ac85af
Showing 1 changed file with 4 additions and 4 deletions.
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()

0 comments on commit 0ac85af

Please sign in to comment.