Skip to content

Commit 0ac85af

Browse files
committed
Remove os dep
1 parent 7acfaeb commit 0ac85af

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/pytest_mypy.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""Mypy static type checker plugin for Pytest"""
22

33
import json
4-
import os
54
from pathlib import Path
65
from tempfile import NamedTemporaryFile
76
from typing import Dict, List, Optional, TextIO
@@ -232,16 +231,17 @@ def from_mypy(
232231
str(path.absolute()): [] for path in paths
233232
} # type: MypyResults._abspath_errors_type
234233

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

239239
unmatched_lines = []
240240
for line in stdout.split("\n"):
241241
if not line:
242242
continue
243243
path, _, error = line.partition(":")
244-
abspath = os.path.abspath(path)
244+
abspath = str(Path(path).absolute())
245245
try:
246246
abspath_errors[abspath].append(error)
247247
except KeyError:
@@ -310,4 +310,4 @@ def pytest_terminal_summary(terminalreporter, config):
310310
terminalreporter.write_line(results.unmatched_stdout, **color)
311311
if results.stderr:
312312
terminalreporter.write_line(results.stderr, yellow=True)
313-
os.remove(config._mypy_results_path)
313+
Path(config._mypy_results_path).unlink()

0 commit comments

Comments
 (0)