Rewrite Item.location to be clearer with regard to types

This commit is contained in:
Ran Benita 2020-01-23 13:25:15 +01:00 committed by Daniel Hahler
parent 0b6258ab5b
commit 9dcdea5de7
1 changed files with 6 additions and 5 deletions

View File

@ -462,9 +462,10 @@ class Item(Node):
@cached_property
def location(self) -> Tuple[str, Optional[int], str]:
location = self.reportinfo()
fspath = location[0]
if not isinstance(fspath, py.path.local):
fspath = py.path.local(fspath)
fspath = self.session._node_location_to_relpath(fspath)
if isinstance(location[0], py.path.local):
fspath = location[0]
else:
fspath = py.path.local(location[0])
relfspath = self.session._node_location_to_relpath(fspath)
assert type(location[2]) is str
return (fspath, location[1], location[2])
return (relfspath, location[1], location[2])