Skip to content

Commit e5e47c1

Browse files
committed
Fix typing related to iniconfig
iniconfig now has typing stubs which reveal a couple issues.
1 parent 0a258f5 commit e5e47c1

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ repos:
5454
- id: mypy
5555
files: ^(src/|testing/)
5656
args: []
57+
additional_dependencies:
58+
- iniconfig>=1.1.0
5759
- repo: local
5860
hooks:
5961
- id: rst

src/_pytest/config/findpaths.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def _parse_ini_config(path: Path) -> iniconfig.IniConfig:
2727
Raise UsageError if the file cannot be parsed.
2828
"""
2929
try:
30-
return iniconfig.IniConfig(path)
30+
return iniconfig.IniConfig(str(path))
3131
except iniconfig.ParseError as exc:
3232
raise UsageError(str(exc)) from exc
3333

src/_pytest/pytester.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import attr
3333
import py
3434
from iniconfig import IniConfig
35+
from iniconfig import SectionWrapper
3536

3637
import pytest
3738
from _pytest import timing
@@ -785,10 +786,10 @@ def makeini(self, source: str) -> Path:
785786
"""Write a tox.ini file with 'source' as contents."""
786787
return self.makefile(".ini", tox=source)
787788

788-
def getinicfg(self, source: str) -> IniConfig:
789+
def getinicfg(self, source: str) -> SectionWrapper:
789790
"""Return the pytest section from the tox.ini config file."""
790791
p = self.makeini(source)
791-
return IniConfig(p)["pytest"]
792+
return IniConfig(str(p))["pytest"]
792793

793794
def makepyprojecttoml(self, source: str) -> Path:
794795
"""Write a pyproject.toml file with 'source' as contents.
@@ -1541,9 +1542,9 @@ def makeini(self, source) -> py.path.local:
15411542
"""See :meth:`Pytester.makeini`."""
15421543
return py.path.local(str(self._pytester.makeini(source)))
15431544

1544-
def getinicfg(self, source) -> py.path.local:
1545+
def getinicfg(self, source: str) -> SectionWrapper:
15451546
"""See :meth:`Pytester.getinicfg`."""
1546-
return py.path.local(str(self._pytester.getinicfg(source)))
1547+
return self._pytester.getinicfg(source)
15471548

15481549
def makepyprojecttoml(self, source) -> py.path.local:
15491550
"""See :meth:`Pytester.makepyprojecttoml`."""

0 commit comments

Comments
 (0)