Skip to content

Commit 0253ff1

Browse files
implement review comments
1 parent 10583b8 commit 0253ff1

6 files changed

Lines changed: 24 additions & 16 deletions

File tree

.pre-commit-config.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@ repos:
1010
- id: setup-cfg-fmt
1111
args: [--include-version-classifiers]
1212
- repo: https://github.com/psf/black
13-
rev: 22.10.0
13+
rev: 22.12.0
1414
hooks:
1515
- id: black
1616
language_version: python3
1717
- repo: https://github.com/pre-commit/mirrors-mypy
1818
rev: 'v0.991'
1919
hooks:
2020
- id: mypy
21+
args: []
2122
additional_dependencies:
22-
- "pytest==7.2.0"
23+
- "pytest==7.2.0"
24+
- "tomli"

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ build-backend = "setuptools.build_meta"
66
[tool.setuptools_scm]
77

88
[tool.mypy]
9-
strict = true
9+
strict = true

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ url = https://github.com/RonnyPfannschmidt/iniconfig
77
author = Ronny Pfannschmidt, Holger Krekel
88
author_email = pensource@ronnypfannschmidt.de, holger.krekel@gmail.com
99
license = MIT
10-
license_file = LICENSE
10+
license_files = LICENSE
1111
platforms = unix, linux, osx, cygwin, win32
1212
classifiers =
1313
Development Status :: 4 - Beta

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
from setuptools import setup
1+
from setuptools import setup # type: ignore[import]
22

33
# Ensures that setuptools_scm is installed, so wheels get proper versions
4-
import setuptools_scm # noqa
4+
import setuptools_scm # type: ignore[import]
55

66

77
def local_scheme(version: object) -> str:

src/iniconfig/__init__.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
cast,
1818
)
1919

20+
import os
2021

2122
if TYPE_CHECKING:
2223
from typing_extensions import Final
@@ -35,7 +36,7 @@ class SectionWrapper:
3536
config: Final[IniConfig]
3637
name: Final[str]
3738

38-
def __init__(self, config: IniConfig, name: str):
39+
def __init__(self, config: IniConfig, name: str) -> None:
3940
self.config = config
4041
self.name = name
4142

@@ -57,7 +58,7 @@ def __iter__(self) -> Iterator[str]:
5758
section: Mapping[str, str] = self.config.sections.get(self.name, {})
5859

5960
def lineof(key: str) -> int:
60-
return self.config.lineof(self.name, key) # type: ignore
61+
return self.config.lineof(self.name, key) # type: ignore[return-value]
6162

6263
yield from sorted(section, key=lineof)
6364

@@ -71,30 +72,35 @@ class IniConfig:
7172
sections: Final[Mapping[str, Mapping[str, str]]]
7273

7374
def __init__(
74-
self, path: str, data: str | None = None, encoding: str = "utf-8"
75+
self,
76+
path: str | os.PathLike[str],
77+
data: str | None = None,
78+
encoding: str = "utf-8",
7579
) -> None:
76-
self.path = str(path) # convenience
80+
self.path = os.fspath(path)
7781
if data is None:
7882
with open(self.path, encoding=encoding) as fp:
7983
data = fp.read()
8084

81-
tokens = _parse.parse_lines(path, data.splitlines(True))
85+
tokens = _parse.parse_lines(self.path, data.splitlines(True))
8286

8387
self._sources = {}
8488
sections_data: dict[str, dict[str, str]]
8589
self.sections = sections_data = {}
8690

8791
for lineno, section, name, value in tokens:
8892
if section is None:
89-
raise ParseError(path, lineno, "no section header defined")
93+
raise ParseError(self.path, lineno, "no section header defined")
9094
self._sources[section, name] = lineno
9195
if name is None:
9296
if section in self.sections:
93-
raise ParseError(path, lineno, f"duplicate section {section!r}")
97+
raise ParseError(
98+
self.path, lineno, f"duplicate section {section!r}"
99+
)
94100
sections_data[section] = {}
95101
else:
96102
if name in self.sections[section]:
97-
raise ParseError(path, lineno, f"duplicate name {name!r}")
103+
raise ParseError(self.path, lineno, f"duplicate name {name!r}")
98104
assert value is not None
99105
sections_data[section][name] = value
100106

src/iniconfig/exceptions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ class ParseError(Exception):
1010
lineno: Final[int]
1111
msg: Final[str]
1212

13-
def __init__(self, path: str, lineno: int, msg: str):
14-
Exception.__init__(self, path, lineno, msg)
13+
def __init__(self, path: str, lineno: int, msg: str) -> None:
14+
super().__init__(path, lineno, msg)
1515
self.path = path
1616
self.lineno = lineno
1717
self.msg = msg

0 commit comments

Comments
 (0)