Skip to content

Commit d347a30

Browse files
authored
Merge pull request #6510 from blueyed/typing-fixes
typing: fix some "incompatible types in assignment" with py
2 parents 32b62f7 + aaae43e commit d347a30

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/_pytest/compat.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,10 @@ def getlocation(function, curdir=None) -> str:
9797
function = get_real_func(function)
9898
fn = py.path.local(inspect.getfile(function))
9999
lineno = function.__code__.co_firstlineno
100-
if curdir is not None and fn.relto(curdir):
101-
fn = fn.relto(curdir)
100+
if curdir is not None:
101+
relfn = fn.relto(curdir)
102+
if relfn:
103+
return "%s:%d" % (relfn, lineno + 1)
102104
return "%s:%d" % (fn, lineno + 1)
103105

104106

src/_pytest/config/findpaths.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ def determine_setup(
121121
sections = ["tool:pytest", "pytest"] if is_cfg_file else ["pytest"]
122122
for section in sections:
123123
try:
124-
inicfg = iniconfig[section]
124+
inicfg = iniconfig[
125+
section
126+
] # type: Optional[py.iniconfig._SectionWrapper]
125127
if is_cfg_file and section == "pytest" and config is not None:
126128
fail(
127129
CFG_PYTEST_SECTION.format(filename=str(inifile)), pytrace=False

0 commit comments

Comments
 (0)