diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2cda2619..50e8132a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,7 +16,7 @@ exclude: > repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 + rev: v4.4.0 hooks: - id: check-json - id: check-yaml @@ -24,23 +24,23 @@ repos: - id: trailing-whitespace - repo: https://github.com/pycqa/isort - rev: 5.10.1 + rev: 5.12.0 hooks: - id: isort - repo: https://github.com/psf/black - rev: 22.6.0 + rev: 23.1.0 hooks: - id: black - repo: https://github.com/PyCQA/flake8 - rev: 5.0.2 + rev: 6.0.0 hooks: - id: flake8 additional_dependencies: [flake8-bugbear~=22.7] - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.971 + rev: v1.0.1 hooks: - id: mypy additional_dependencies: [mdurl] diff --git a/markdown_it/common/utils.py b/markdown_it/common/utils.py index edc24ca5..9b7c4aeb 100644 --- a/markdown_it/common/utils.py +++ b/markdown_it/common/utils.py @@ -56,7 +56,6 @@ def arrayReplaceAt(src: list, pos: int, newElements: list) -> list: def isValidEntityCode(c: int) -> bool: - # broken sequence if c >= 0xD800 and c <= 0xDFFF: return False diff --git a/markdown_it/helpers/parse_link_label.py b/markdown_it/helpers/parse_link_label.py index 20e3c148..6ce8daf8 100644 --- a/markdown_it/helpers/parse_link_label.py +++ b/markdown_it/helpers/parse_link_label.py @@ -9,7 +9,6 @@ def parseLinkLabel(state: StateInline, start: int, disableNested: bool = False) -> int: - labelEnd = -1 oldPos = state.pos found = False diff --git a/markdown_it/renderer.py b/markdown_it/renderer.py index b8bfe4da..aa6272a3 100644 --- a/markdown_it/renderer.py +++ b/markdown_it/renderer.py @@ -18,7 +18,7 @@ class Renderer try: from typing import Protocol except ImportError: # Python <3.8 doesn't have `Protocol` in the stdlib - from typing_extensions import Protocol # type: ignore[misc] + from typing_extensions import Protocol # type: ignore class RendererProtocol(Protocol): @@ -82,7 +82,6 @@ def render( result = "" for i, token in enumerate(tokens): - if token.type == "inline": assert token.children is not None result += self.renderInline(token.children, options, env) diff --git a/markdown_it/rules_block/blockquote.py b/markdown_it/rules_block/blockquote.py index 6575731d..e00fbf61 100644 --- a/markdown_it/rules_block/blockquote.py +++ b/markdown_it/rules_block/blockquote.py @@ -10,7 +10,6 @@ def blockquote(state: StateBlock, startLine: int, endLine: int, silent: bool): - LOGGER.debug( "entering blockquote: %s, %s, %s, %s", state, startLine, endLine, silent ) @@ -129,7 +128,6 @@ def blockquote(state: StateBlock, startLine: int, endLine: int, silent: bool): # for (nextLine = startLine + 1; nextLine < endLine; nextLine++) { nextLine = startLine + 1 while nextLine < endLine: - # check if it's outdented, i.e. it's inside list item and indented # less than said list item: # diff --git a/markdown_it/rules_block/code.py b/markdown_it/rules_block/code.py index c4fdba33..a796608d 100644 --- a/markdown_it/rules_block/code.py +++ b/markdown_it/rules_block/code.py @@ -7,7 +7,6 @@ def code(state: StateBlock, startLine: int, endLine: int, silent: bool = False): - LOGGER.debug("entering code: %s, %s, %s, %s", state, startLine, endLine, silent) if state.sCount[startLine] - state.blkIndent < 4: diff --git a/markdown_it/rules_block/fence.py b/markdown_it/rules_block/fence.py index c4f5275d..fb3c6847 100644 --- a/markdown_it/rules_block/fence.py +++ b/markdown_it/rules_block/fence.py @@ -7,7 +7,6 @@ def fence(state: StateBlock, startLine: int, endLine: int, silent: bool): - LOGGER.debug("entering fence: %s, %s, %s, %s", state, startLine, endLine, silent) haveEndMarker = False diff --git a/markdown_it/rules_block/heading.py b/markdown_it/rules_block/heading.py index 8d4ef3e2..064d0702 100644 --- a/markdown_it/rules_block/heading.py +++ b/markdown_it/rules_block/heading.py @@ -10,7 +10,6 @@ def heading(state: StateBlock, startLine: int, endLine: int, silent: bool): - LOGGER.debug("entering heading: %s, %s, %s, %s", state, startLine, endLine, silent) pos = state.bMarks[startLine] + state.tShift[startLine] diff --git a/markdown_it/rules_block/hr.py b/markdown_it/rules_block/hr.py index 804cd9db..22c69722 100644 --- a/markdown_it/rules_block/hr.py +++ b/markdown_it/rules_block/hr.py @@ -11,7 +11,6 @@ def hr(state: StateBlock, startLine: int, endLine: int, silent: bool): - LOGGER.debug("entering hr: %s, %s, %s, %s", state, startLine, endLine, silent) pos = state.bMarks[startLine] + state.tShift[startLine] diff --git a/markdown_it/rules_block/lheading.py b/markdown_it/rules_block/lheading.py index f26e2af0..92632acc 100644 --- a/markdown_it/rules_block/lheading.py +++ b/markdown_it/rules_block/lheading.py @@ -8,7 +8,6 @@ def lheading(state: StateBlock, startLine: int, endLine: int, silent: bool): - LOGGER.debug("entering lheading: %s, %s, %s, %s", state, startLine, endLine, silent) level = None diff --git a/markdown_it/rules_block/list.py b/markdown_it/rules_block/list.py index a7617ad2..9cf8c402 100644 --- a/markdown_it/rules_block/list.py +++ b/markdown_it/rules_block/list.py @@ -10,7 +10,6 @@ # Search `[-+*][\n ]`, returns next pos after marker on success # or -1 on fail. def skipBulletListMarker(state: StateBlock, startLine: int): - pos = state.bMarks[startLine] + state.tShift[startLine] maximum = state.eMarks[startLine] @@ -33,7 +32,6 @@ def skipBulletListMarker(state: StateBlock, startLine: int): # Search `\d+[.)][\n ]`, returns next pos after marker on success # or -1 on fail. def skipOrderedListMarker(state: StateBlock, startLine: int): - start = state.bMarks[startLine] + state.tShift[startLine] pos = start maximum = state.eMarks[startLine] @@ -59,7 +57,6 @@ def skipOrderedListMarker(state: StateBlock, startLine: int): # /* 0 */ /* 9 */ if ch >= 0x30 and ch <= 0x39: - # List marker should have no more than 9 digits # (prevents integer overflow in browsers) if pos - start >= 10: @@ -97,7 +94,6 @@ def markTightParagraphs(state: StateBlock, idx: int): def list_block(state: StateBlock, startLine: int, endLine: int, silent: bool): - LOGGER.debug("entering list: %s, %s, %s, %s", state, startLine, endLine, silent) isTerminatingParagraph = False diff --git a/markdown_it/rules_block/paragraph.py b/markdown_it/rules_block/paragraph.py index 4fee83e9..fef7edf7 100644 --- a/markdown_it/rules_block/paragraph.py +++ b/markdown_it/rules_block/paragraph.py @@ -8,7 +8,6 @@ def paragraph(state: StateBlock, startLine: int, endLine: int, silent: bool = False): - LOGGER.debug( "entering paragraph: %s, %s, %s, %s", state, startLine, endLine, silent ) diff --git a/markdown_it/rules_block/reference.py b/markdown_it/rules_block/reference.py index 35adde2a..39e21eb6 100644 --- a/markdown_it/rules_block/reference.py +++ b/markdown_it/rules_block/reference.py @@ -7,7 +7,6 @@ def reference(state: StateBlock, startLine, _endLine, silent): - LOGGER.debug( "entering reference: %s, %s, %s, %s", state, startLine, _endLine, silent ) diff --git a/markdown_it/rules_block/state_block.py b/markdown_it/rules_block/state_block.py index 42b8fce3..c5589149 100644 --- a/markdown_it/rules_block/state_block.py +++ b/markdown_it/rules_block/state_block.py @@ -19,7 +19,6 @@ def __init__( tokens: list[Token], srcCharCode: tuple[int, ...] | None = None, ): - if srcCharCode is not None: self._src = src self.srcCharCode = srcCharCode diff --git a/markdown_it/rules_core/block.py b/markdown_it/rules_core/block.py index fa1c52c4..dc756418 100644 --- a/markdown_it/rules_core/block.py +++ b/markdown_it/rules_core/block.py @@ -3,7 +3,6 @@ def block(state: StateCore) -> None: - if state.inlineMode: token = Token("inline", "", 0) token.content = state.src diff --git a/markdown_it/rules_core/normalize.py b/markdown_it/rules_core/normalize.py index bf16fd7a..c9f8d0d5 100644 --- a/markdown_it/rules_core/normalize.py +++ b/markdown_it/rules_core/normalize.py @@ -9,7 +9,6 @@ def normalize(state: StateCore) -> None: - # Normalize newlines string = NEWLINES_RE.sub("\n", state.src) diff --git a/markdown_it/rules_core/smartquotes.py b/markdown_it/rules_core/smartquotes.py index 93f8be28..7a39fad4 100644 --- a/markdown_it/rules_core/smartquotes.py +++ b/markdown_it/rules_core/smartquotes.py @@ -195,7 +195,6 @@ def smartquotes(state: StateCore) -> None: return for token in state.tokens: - if token.type != "inline" or not QUOTE_RE.search(token.content): continue assert token.children is not None diff --git a/markdown_it/rules_inline/autolink.py b/markdown_it/rules_inline/autolink.py index a4ee61c3..11ac5905 100644 --- a/markdown_it/rules_inline/autolink.py +++ b/markdown_it/rules_inline/autolink.py @@ -10,7 +10,6 @@ def autolink(state: StateInline, silent: bool) -> bool: - pos = state.pos if state.srcCharCode[pos] != 0x3C: # /* < */ diff --git a/markdown_it/rules_inline/backticks.py b/markdown_it/rules_inline/backticks.py index 7bff12fe..5f1e0552 100644 --- a/markdown_it/rules_inline/backticks.py +++ b/markdown_it/rules_inline/backticks.py @@ -7,7 +7,6 @@ def backtick(state: StateInline, silent: bool) -> bool: - pos = state.pos ch = state.srcCharCode[pos] diff --git a/markdown_it/rules_inline/balance_pairs.py b/markdown_it/rules_inline/balance_pairs.py index db622f07..5423b5d6 100644 --- a/markdown_it/rules_inline/balance_pairs.py +++ b/markdown_it/rules_inline/balance_pairs.py @@ -4,7 +4,6 @@ def processDelimiters(state: StateInline, delimiters, *args): - openersBottom = {} maximum = len(delimiters) @@ -50,7 +49,6 @@ def processDelimiters(state: StateInline, delimiters, *args): continue if opener.open and opener.end < 0: - isOddMatch = False # from spec: diff --git a/markdown_it/rules_inline/emphasis.py b/markdown_it/rules_inline/emphasis.py index 9001b09e..5262430b 100644 --- a/markdown_it/rules_inline/emphasis.py +++ b/markdown_it/rules_inline/emphasis.py @@ -39,7 +39,6 @@ def tokenize(state: StateInline, silent: bool): def _postProcess(state, delimiters): - i = len(delimiters) - 1 while i >= 0: startDelim = delimiters[i] diff --git a/markdown_it/rules_inline/entity.py b/markdown_it/rules_inline/entity.py index 883a9666..08d271ed 100644 --- a/markdown_it/rules_inline/entity.py +++ b/markdown_it/rules_inline/entity.py @@ -10,7 +10,6 @@ def entity(state: StateInline, silent: bool): - pos = state.pos maximum = state.posMax diff --git a/markdown_it/rules_inline/html_inline.py b/markdown_it/rules_inline/html_inline.py index 295cc5c7..b875e884 100644 --- a/markdown_it/rules_inline/html_inline.py +++ b/markdown_it/rules_inline/html_inline.py @@ -10,7 +10,6 @@ def isLetter(ch: int): def html_inline(state: StateInline, silent: bool): - pos = state.pos if not state.md.options.get("html", None): diff --git a/markdown_it/rules_inline/image.py b/markdown_it/rules_inline/image.py index d2a08d47..d7215bdf 100644 --- a/markdown_it/rules_inline/image.py +++ b/markdown_it/rules_inline/image.py @@ -7,7 +7,6 @@ def image(state: StateInline, silent: bool): - label = None href = "" oldPos = state.pos diff --git a/markdown_it/rules_inline/link.py b/markdown_it/rules_inline/link.py index 2394d6c3..a6345152 100644 --- a/markdown_it/rules_inline/link.py +++ b/markdown_it/rules_inline/link.py @@ -5,7 +5,6 @@ def link(state: StateInline, silent: bool): - href = "" title = "" label = None diff --git a/markdown_it/rules_inline/strikethrough.py b/markdown_it/rules_inline/strikethrough.py index 107ea26b..9b062a66 100644 --- a/markdown_it/rules_inline/strikethrough.py +++ b/markdown_it/rules_inline/strikethrough.py @@ -53,7 +53,6 @@ def tokenize(state: StateInline, silent: bool): def _postProcess(state: StateInline, delimiters: list[Delimiter]): - loneMarkers = [] maximum = len(delimiters) @@ -89,7 +88,6 @@ def _postProcess(state: StateInline, delimiters: list[Delimiter]): state.tokens[endDelim.token - 1].type == "text" and state.tokens[endDelim.token - 1].content == "~" ): - loneMarkers.append(endDelim.token - 1) i += 1 diff --git a/markdown_it/token.py b/markdown_it/token.py index b20875b6..7a41a784 100644 --- a/markdown_it/token.py +++ b/markdown_it/token.py @@ -22,7 +22,6 @@ def convert_attrs(value: Any) -> Any: @dc.dataclass(**DATACLASS_KWARGS) class Token: - type: str """Type of the token (string, e.g. "paragraph_open")""" diff --git a/tests/test_port/test_references.py b/tests/test_port/test_references.py index 32e389de..75bf7130 100644 --- a/tests/test_port/test_references.py +++ b/tests/test_port/test_references.py @@ -2,7 +2,6 @@ def test_ref_definitions(): - md = MarkdownIt() src = "[a]: abc\n\n[b]: xyz\n\n[b]: ijk" env = {}