Skip to content

Commit 20d8e04

Browse files
committed
typing: PyobjMixin.reportinfo, getfslineno
1 parent 5fbda83 commit 20d8e04

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/_pytest/compat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ def get_real_method(obj, holder):
307307
return obj
308308

309309

310-
def getfslineno(obj):
310+
def getfslineno(obj) -> Tuple[Union[str, py.path.local], int]:
311311
# xxx let decorators etc specify a sane ordering
312312
obj = get_real_func(obj)
313313
if hasattr(obj, "place_as"):

src/_pytest/python.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from textwrap import dedent
1313
from typing import List
1414
from typing import Tuple
15+
from typing import Union
1516

1617
import py
1718

@@ -280,15 +281,16 @@ def getmodpath(self, stopatmodule=True, includemodule=False):
280281
parts.reverse()
281282
return ".".join(parts)
282283

283-
def reportinfo(self) -> Tuple[str, int, str]:
284+
def reportinfo(self) -> Tuple[Union[py.path.local, str], int, str]:
284285
# XXX caching?
285286
obj = self.obj
286287
compat_co_firstlineno = getattr(obj, "compat_co_firstlineno", None)
287288
if isinstance(compat_co_firstlineno, int):
288289
# nose compatibility
289-
fspath = sys.modules[obj.__module__].__file__
290-
if fspath.endswith(".pyc"):
291-
fspath = fspath[:-1]
290+
file_path = sys.modules[obj.__module__].__file__
291+
if file_path.endswith(".pyc"):
292+
file_path = file_path[:-1]
293+
fspath = file_path # type: Union[py.path.local, str]
292294
lineno = compat_co_firstlineno
293295
else:
294296
fspath, lineno = getfslineno(obj)

0 commit comments

Comments
 (0)