Skip to content

Commit 29252f8

Browse files
Netzebandmsullivan
authored andcommitted
Bugfix/fix failing tests on windows due to relpath (#8094)
1 parent 63057d8 commit 29252f8

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ This submodule contains types for the Python standard library.
221221

222222
Due to the way git submodules work, you'll have to do
223223
```
224-
git submodule update typeshed
224+
git submodule update mypy/typeshed
225225
```
226226
whenever you change branches, merge, rebase, or pull.
227227

mypy/report.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,12 @@ def on_file(self,
459459
type_map: Dict[Expression, Type],
460460
options: Options) -> None:
461461
self.last_xml = None
462-
path = os.path.relpath(tree.path)
462+
463+
try:
464+
path = os.path.relpath(tree.path)
465+
except ValueError:
466+
return
467+
463468
if should_skip_path(path):
464469
return
465470

@@ -813,7 +818,12 @@ def on_file(self,
813818
modules: Dict[str, MypyFile],
814819
type_map: Dict[Expression, Type],
815820
options: Options) -> None:
816-
path = os.path.relpath(tree.path)
821+
822+
try:
823+
path = os.path.relpath(tree.path)
824+
except ValueError:
825+
return
826+
817827
if should_skip_path(path):
818828
return
819829

test-data/unit/check-incremental.test

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4117,7 +4117,9 @@ class C:
41174117
[out2]
41184118
main:5: error: Incompatible types in assignment (expression has type "str", variable has type "int")
41194119

4120-
[case testBazelFlagIgnoresFileChanges]
4120+
[case testBazelFlagIgnoresFileChanges-skip]
4121+
-- This test fails on windows, when the mypy source in on a different drive than
4122+
-- the run-directory. In this case os.path.relpath(...) fails with an exception
41214123
-- Since the initial run wrote a cache file, the second run ignores the source
41224124
# flags: --bazel
41234125
from a import f

0 commit comments

Comments
 (0)