File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11"""Mypy static type checker plugin for Pytest"""
22
33import json
4- import os
54from pathlib import Path
65from tempfile import NamedTemporaryFile
76from 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 ( )
You can’t perform that action at this time.
0 commit comments