Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
rev: v3.20.0
hooks:
- id: pyupgrade
args: [--py38-plus]
- repo: https://github.com/tox-dev/pyproject-fmt
rev: "0.4.1"
rev: "v2.6.0"
hooks:
- id: pyproject-fmt

- repo: https://github.com/psf/black
rev: 22.12.0
rev: 25.1.0
hooks:
- id: black
language_version: python3
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v0.991'
rev: 'v1.17.0'
hooks:
- id: mypy
args: []
Expand Down
58 changes: 27 additions & 31 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,33 @@ description = "brain-dead simple config-ini parsing"
readme = "README.rst"
license = "MIT"
authors = [
{ name = "Ronny Pfannschmidt", email = "opensource@ronnypfannschmidt.de" },
{ name = "Holger Krekel", email = "holger.krekel@gmail.com" },
{ name = "Ronny Pfannschmidt", email = "opensource@ronnypfannschmidt.de" },
{ name = "Holger Krekel", email = "holger.krekel@gmail.com" },
]
requires-python = ">=3.8"
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Software Development :: Libraries",
"Topic :: Utilities",
]
dynamic = [
"version",
]
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Software Development :: Libraries",
"Topic :: Utilities",
]
[project.urls]
Homepage = "https://github.com/pytest-dev/iniconfig"
urls.Homepage = "https://github.com/pytest-dev/iniconfig"

[tool.setuptools_scm]

[tool.hatch.version]
source = "vcs"
Expand All @@ -48,25 +47,22 @@ version-file = "src/iniconfig/_version.py"

[tool.hatch.build.targets.sdist]
include = [
"/src",
"/testing",
"/src",
"/testing",
]

[tool.hatch.envs.test]
dependencies = [
"pytest"
"pytest",
]
[tool.hatch.envs.test.scripts]
default = "pytest {args}"

[[tool.hatch.envs.test.matrix]]
python = ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
python = [ "3.8", "3.9", "3.10", "3.11", "3.12", "3.13" ]

[tool.setuptools_scm]
[tool.pytest.ini_options]
testpaths = "testing"

[tool.mypy]
strict = true


[tool.pytest.ini_options]
testpaths = "testing"
39 changes: 12 additions & 27 deletions src/iniconfig/__init__.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
""" brain-dead simple parser for ini-style files.
"""brain-dead simple parser for ini-style files.
(C) Ronny Pfannschmidt, Holger Krekel -- MIT licensed
"""

from __future__ import annotations
from typing import (
Callable,
Iterator,
Mapping,
Optional,
Tuple,
TypeVar,
Union,
TYPE_CHECKING,
NoReturn,
NamedTuple,
overload,
cast,
)

import os
Expand Down Expand Up @@ -44,38 +39,33 @@ def lineof(self, name: str) -> int | None:
return self.config.lineof(self.name, name)

@overload
def get(self, key: str) -> str | None:
...
def get(self, key: str) -> str | None: ...

@overload
def get(
self,
key: str,
convert: Callable[[str], _T],
) -> _T | None:
...
) -> _T | None: ...

@overload
def get(
self,
key: str,
default: None,
convert: Callable[[str], _T],
) -> _T | None:
...
) -> _T | None: ...

@overload
def get(self, key: str, default: _D, convert: None = None) -> str | _D:
...
def get(self, key: str, default: _D, convert: None = None) -> str | _D: ...

@overload
def get(
self,
key: str,
default: _D,
convert: Callable[[str], _T],
) -> _T | _D:
...
) -> _T | _D: ...

# TODO: investigate possible mypy bug wrt matching the passed over data
def get( # type: ignore [misc]
Expand Down Expand Up @@ -148,17 +138,15 @@ def get(
self,
section: str,
name: str,
) -> str | None:
...
) -> str | None: ...

@overload
def get(
self,
section: str,
name: str,
convert: Callable[[str], _T],
) -> _T | None:
...
) -> _T | None: ...

@overload
def get(
Expand All @@ -167,14 +155,12 @@ def get(
name: str,
default: None,
convert: Callable[[str], _T],
) -> _T | None:
...
) -> _T | None: ...

@overload
def get(
self, section: str, name: str, default: _D, convert: None = None
) -> str | _D:
...
) -> str | _D: ...

@overload
def get(
Expand All @@ -183,8 +169,7 @@ def get(
name: str,
default: _D,
convert: Callable[[str], _T],
) -> _T | _D:
...
) -> _T | _D: ...

def get( # type: ignore
self,
Expand Down