Skip to content

Commit af4db3b

Browse files
committed
Misc: Enable more linting rules and adapt code for them
1 parent 715b36e commit af4db3b

3 files changed

Lines changed: 14 additions & 10 deletions

File tree

mdit_py_toc/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
from .plugin import slugify, toc_plugin
22

3-
__all__ = ("toc_plugin", "slugify")
3+
__all__ = (
4+
"slugify",
5+
"toc_plugin",
6+
)

mdit_py_toc/plugin.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import functools
22
import re
3+
from collections.abc import Iterable, Sequence
34
from dataclasses import dataclass, field
4-
from typing import Callable, Iterable, Optional, Sequence, Union
5+
from typing import Callable, Optional, Union
56

67
from markdown_it import MarkdownIt
78
from markdown_it.common.utils import escapeHtml
@@ -109,12 +110,12 @@ def __call__(
109110
def _toc(
110111
self,
111112
state: StateBlock,
112-
startLine: int,
113-
endLine: int,
113+
start_line: int,
114+
end_line: int,
114115
silent: bool,
115116
) -> bool:
116-
pos = state.bMarks[startLine] + state.tShift[startLine]
117-
max = state.eMarks[startLine]
117+
pos = state.bMarks[start_line] + state.tShift[start_line]
118+
max = state.eMarks[start_line] # noqa: A001
118119

119120
# use whitespace as a line tokenizer and extract the first token
120121
# to test against the placeholder anchored pattern, rejecting if false
@@ -126,15 +127,15 @@ def _toc(
126127
if silent:
127128
return True
128129

129-
state.line = startLine + 1
130+
state.line = start_line + 1
130131

131132
token = state.push("toc_open", "nav", 1)
132133
token.markup = ""
133-
token.map = [startLine, state.line]
134+
token.map = [start_line, state.line]
134135

135136
token = state.push("toc_body", "", 0)
136137
token.markup = ""
137-
token.map = [startLine, state.line]
138+
token.map = [start_line, state.line]
138139
token.children = []
139140

140141
token = state.push("toc_close", "nav", -1)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ line-length = 80
5454
target-version = "py39"
5555

5656
[tool.ruff.lint]
57-
extend-select = ["I", "PLE", "PLW"]
57+
extend-select = ["I", "PLE", "PLW", "PTH", "C4", "A", "N", "RUF", "UP"]
5858

5959
[tool.mypy]
6060
files = "mdit_py_toc"

0 commit comments

Comments
 (0)