From aaae43e0badd5f1c681e5010759e47c1f49d1f88 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 19 Jan 2020 11:28:07 +0100 Subject: [PATCH] typing: fix some "incompatible types in assignment" with py --- src/_pytest/compat.py | 6 ++++-- src/_pytest/config/findpaths.py | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/_pytest/compat.py b/src/_pytest/compat.py index cc5140b0c..6a62e88cf 100644 --- a/src/_pytest/compat.py +++ b/src/_pytest/compat.py @@ -97,8 +97,10 @@ def getlocation(function, curdir=None) -> str: function = get_real_func(function) fn = py.path.local(inspect.getfile(function)) lineno = function.__code__.co_firstlineno - if curdir is not None and fn.relto(curdir): - fn = fn.relto(curdir) + if curdir is not None: + relfn = fn.relto(curdir) + if relfn: + return "%s:%d" % (relfn, lineno + 1) return "%s:%d" % (fn, lineno + 1) diff --git a/src/_pytest/config/findpaths.py b/src/_pytest/config/findpaths.py index d9b5f7543..707ce969d 100644 --- a/src/_pytest/config/findpaths.py +++ b/src/_pytest/config/findpaths.py @@ -121,7 +121,9 @@ def determine_setup( sections = ["tool:pytest", "pytest"] if is_cfg_file else ["pytest"] for section in sections: try: - inicfg = iniconfig[section] + inicfg = iniconfig[ + section + ] # type: Optional[py.iniconfig._SectionWrapper] if is_cfg_file and section == "pytest" and config is not None: fail( CFG_PYTEST_SECTION.format(filename=str(inifile)), pytrace=False