fix code passing ruff linter pre-commit ruff pre-commit ruff format
This commit is contained in:
@@ -1,8 +1,13 @@
|
||||
from typing import TYPE_CHECKING, List
|
||||
|
||||
from . import compat
|
||||
from .ini import EmptyLine, LineContainer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .ini import LineType
|
||||
|
||||
def tidy(cfg):
|
||||
|
||||
def tidy(cfg: compat.RawConfigParser):
|
||||
"""Clean up blank lines.
|
||||
|
||||
This functions makes the configuration look clean and
|
||||
@@ -19,8 +24,7 @@ def tidy(cfg):
|
||||
if isinstance(cont[i], LineContainer):
|
||||
tidy_section(cont[i])
|
||||
i += 1
|
||||
elif (isinstance(cont[i-1], EmptyLine) and
|
||||
isinstance(cont[i], EmptyLine)):
|
||||
elif isinstance(cont[i - 1], EmptyLine) and isinstance(cont[i], EmptyLine):
|
||||
del cont[i]
|
||||
else:
|
||||
i += 1
|
||||
@@ -34,11 +38,11 @@ def tidy(cfg):
|
||||
cont.append(EmptyLine())
|
||||
|
||||
|
||||
def tidy_section(lc):
|
||||
cont = lc.contents
|
||||
i = 1
|
||||
def tidy_section(lc: "LineContainer"):
|
||||
cont: List[LineType] = lc.contents
|
||||
i: int = 1
|
||||
while i < len(cont):
|
||||
if isinstance(cont[i-1], EmptyLine) and isinstance(cont[i], EmptyLine):
|
||||
if isinstance(cont[i - 1], EmptyLine) and isinstance(cont[i], EmptyLine):
|
||||
del cont[i]
|
||||
else:
|
||||
i += 1
|
||||
|
||||
Reference in New Issue
Block a user