mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-12 14:04:17 +00:00
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
72ad6dc953
commit
f4cd1ba0d6
813 changed files with 66015 additions and 58839 deletions
|
|
@ -2,34 +2,32 @@
|
|||
(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
|
||||
from typing import Callable
|
||||
from typing import cast
|
||||
from typing import Iterator
|
||||
from typing import Mapping
|
||||
from typing import NamedTuple
|
||||
from typing import NoReturn
|
||||
from typing import Optional
|
||||
from typing import overload
|
||||
from typing import Tuple
|
||||
from typing import TYPE_CHECKING
|
||||
from typing import TypeVar
|
||||
from typing import Union
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing_extensions import Final
|
||||
from typing import Final
|
||||
|
||||
__all__ = ["IniConfig", "ParseError", "COMMENTCHARS", "iscommentline"]
|
||||
__all__ = ['IniConfig', 'ParseError', 'COMMENTCHARS', 'iscommentline']
|
||||
|
||||
from .exceptions import ParseError
|
||||
from . import _parse
|
||||
from ._parse import COMMENTCHARS, iscommentline
|
||||
|
||||
_D = TypeVar("_D")
|
||||
_T = TypeVar("_T")
|
||||
_D = TypeVar('_D')
|
||||
_T = TypeVar('_T')
|
||||
|
||||
|
||||
class SectionWrapper:
|
||||
|
|
@ -110,7 +108,7 @@ class IniConfig:
|
|||
self,
|
||||
path: str | os.PathLike[str],
|
||||
data: str | None = None,
|
||||
encoding: str = "utf-8",
|
||||
encoding: str = 'utf-8',
|
||||
) -> None:
|
||||
self.path = os.fspath(path)
|
||||
if data is None:
|
||||
|
|
@ -125,17 +123,17 @@ class IniConfig:
|
|||
|
||||
for lineno, section, name, value in tokens:
|
||||
if section is None:
|
||||
raise ParseError(self.path, lineno, "no section header defined")
|
||||
raise ParseError(self.path, lineno, 'no section header defined')
|
||||
self._sources[section, name] = lineno
|
||||
if name is None:
|
||||
if section in self.sections:
|
||||
raise ParseError(
|
||||
self.path, lineno, f"duplicate section {section!r}"
|
||||
self.path, lineno, f'duplicate section {section!r}',
|
||||
)
|
||||
sections_data[section] = {}
|
||||
else:
|
||||
if name in self.sections[section]:
|
||||
raise ParseError(self.path, lineno, f"duplicate name {name!r}")
|
||||
raise ParseError(self.path, lineno, f'duplicate name {name!r}')
|
||||
assert value is not None
|
||||
sections_data[section][name] = value
|
||||
|
||||
|
|
@ -172,7 +170,7 @@ class IniConfig:
|
|||
|
||||
@overload
|
||||
def get(
|
||||
self, section: str, name: str, default: _D, convert: None = None
|
||||
self, section: str, name: str, default: _D, convert: None = None,
|
||||
) -> str | _D:
|
||||
...
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue