Skip to content

Commit 063268b

Browse files
authored
🔧 MAINTAIN: Add isort hook (#210)
1 parent cb2eee1 commit 063268b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+79
-81
lines changed

.pre-commit-config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ repos:
2323
- id: end-of-file-fixer
2424
- id: trailing-whitespace
2525

26+
- repo: https://github.com/pycqa/isort
27+
rev: 5.10.1
28+
hooks:
29+
- id: isort
30+
2631
- repo: https://github.com/psf/black
2732
rev: 22.3.0
2833
hooks:

benchmarking/bench_core.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from pathlib import Path
2+
23
import pytest
34

45
import markdown_it

benchmarking/bench_packages.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from pathlib import Path
2-
import pytest
32
from shutil import which
43

4+
import pytest
5+
56

67
@pytest.fixture
78
def spec_text():

docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ def run_apidoc(app):
9292
"""
9393
import os
9494
import shutil
95+
9596
import sphinx
9697
from sphinx.ext import apidoc
9798

markdown_it/cli/parse.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from markdown_it import __version__
1414
from markdown_it.main import MarkdownIt
1515

16-
1716
version_str = "markdown-it-py [version {}]".format(__version__)
1817

1918

markdown_it/common/normalize_url.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22

33
from collections.abc import Callable
44
import re
5-
from urllib.parse import urlparse, urlunparse, quote, unquote # noqa: F401
5+
from urllib.parse import quote, unquote, urlparse, urlunparse # noqa: F401
66

77
import mdurl
88

99
from .. import _punycode
1010

11-
1211
RECODE_HOSTNAME_FOR = ("http:", "https:", "mailto:")
1312

1413

markdown_it/helpers/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Functions for parsing Links
22
"""
33
__all__ = ("parseLinkLabel", "parseLinkDestination", "parseLinkTitle")
4-
from .parse_link_label import parseLinkLabel
54
from .parse_link_destination import parseLinkDestination
5+
from .parse_link_label import parseLinkLabel
66
from .parse_link_title import parseLinkTitle

markdown_it/helpers/parse_link_destination.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Parse link destination
33
"""
44

5-
from ..common.utils import unescapeAll, charCodeAt
5+
from ..common.utils import charCodeAt, unescapeAll
66

77

88
class _Result:

markdown_it/helpers/parse_link_title.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Parse link title
22
"""
3-
from ..common.utils import unescapeAll, charCodeAt
3+
from ..common.utils import charCodeAt, unescapeAll
44

55

66
class _Result:

markdown_it/main.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
from __future__ import annotations
22

3-
from contextlib import contextmanager
43
from collections.abc import Callable, Generator, Iterable, Mapping, MutableMapping
4+
from contextlib import contextmanager
55
from typing import Any
66

77
from . import helpers, presets # noqa F401
88
from .common import normalize_url, utils # noqa F401
9-
from .token import Token
10-
from .parser_core import ParserCore # noqa F401
119
from .parser_block import ParserBlock # noqa F401
10+
from .parser_core import ParserCore # noqa F401
1211
from .parser_inline import ParserInline # noqa F401
13-
from .rules_core.state_core import StateCore
1412
from .renderer import RendererHTML, RendererProtocol
13+
from .rules_core.state_core import StateCore
14+
from .token import Token
1515
from .utils import OptionsDict
1616

1717
try:

markdown_it/parser_block.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44
import logging
55

6+
from . import rules_block
67
from .ruler import Ruler
7-
from .token import Token
88
from .rules_block.state_block import StateBlock
9-
from . import rules_block
9+
from .token import Token
1010

1111
LOGGER = logging.getLogger(__name__)
1212

markdown_it/parser_core.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66
"""
77
from __future__ import annotations
88

9-
from .ruler import Ruler, RuleFunc
9+
from .ruler import RuleFunc, Ruler
10+
from .rules_core import block, inline, linkify, normalize, replace, smartquotes
1011
from .rules_core.state_core import StateCore
11-
from .rules_core import normalize, block, inline, replace, smartquotes, linkify
12-
1312

1413
_rules: list[tuple[str, RuleFunc]] = [
1514
("normalize", normalize),

markdown_it/parser_inline.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
"""
33
from __future__ import annotations
44

5-
from .ruler import Ruler, RuleFunc
6-
from .token import Token
7-
from .rules_inline.state_inline import StateInline
85
from . import rules_inline
6+
from .ruler import RuleFunc, Ruler
7+
from .rules_inline.state_inline import StateInline
8+
from .token import Token
99

1010
# Parser rules
1111
_rules: list[tuple[str, RuleFunc]] = [

markdown_it/renderer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Renderer
1111
import inspect
1212
from typing import Any, ClassVar
1313

14-
from .common.utils import unescapeAll, escapeHtml
14+
from .common.utils import escapeHtml, unescapeAll
1515
from .token import Token
1616
from .utils import OptionsDict
1717

markdown_it/ruler.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class Ruler
1919

2020
from collections.abc import Callable, Iterable, MutableMapping
2121
from typing import TYPE_CHECKING
22+
2223
import attr
2324

2425
if TYPE_CHECKING:

markdown_it/rules_block/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
"table",
1414
)
1515

16-
from .state_block import StateBlock
17-
from .paragraph import paragraph
18-
from .heading import heading
19-
from .lheading import lheading
16+
from .blockquote import blockquote
2017
from .code import code
2118
from .fence import fence
19+
from .heading import heading
2220
from .hr import hr
21+
from .html_block import html_block
22+
from .lheading import lheading
2323
from .list import list_block
24+
from .paragraph import paragraph
2425
from .reference import reference
25-
from .blockquote import blockquote
26-
from .html_block import html_block
26+
from .state_block import StateBlock
2727
from .table import table

markdown_it/rules_block/blockquote.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
import logging
55

6-
from .state_block import StateBlock
76
from ..common.utils import isSpace
7+
from .state_block import StateBlock
88

99
LOGGER = logging.getLogger(__name__)
1010

markdown_it/rules_block/code.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Code block (4 spaces padded)."""
22
import logging
3+
34
from .state_block import StateBlock
45

56
LOGGER = logging.getLogger(__name__)

markdown_it/rules_block/heading.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
import logging
55

6-
from .state_block import StateBlock
76
from ..common.utils import isSpace
7+
from .state_block import StateBlock
88

99
LOGGER = logging.getLogger(__name__)
1010

markdown_it/rules_block/hr.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from ..common.utils import isSpace
88
from .state_block import StateBlock
99

10-
1110
LOGGER = logging.getLogger(__name__)
1211

1312

markdown_it/rules_block/html_block.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
import logging
55
import re
66

7-
from .state_block import StateBlock
87
from ..common.html_blocks import block_names
98
from ..common.html_re import HTML_OPEN_CLOSE_TAG_STR
9+
from .state_block import StateBlock
1010

1111
LOGGER = logging.getLogger(__name__)
1212

markdown_it/rules_block/list.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Lists
22
import logging
33

4-
from .state_block import StateBlock
54
from ..common.utils import isSpace
5+
from .state_block import StateBlock
66

77
LOGGER = logging.getLogger(__name__)
88

markdown_it/rules_block/reference.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import logging
22

3-
from ..common.utils import isSpace, normalizeReference, charCodeAt
3+
from ..common.utils import charCodeAt, isSpace, normalizeReference
44
from .state_block import StateBlock
55

6-
76
LOGGER = logging.getLogger(__name__)
87

98

markdown_it/rules_block/state_block.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
from typing import TYPE_CHECKING
44

5-
from ..token import Token
6-
from ..ruler import StateBase
75
from ..common.utils import isSpace
6+
from ..ruler import StateBase
7+
from ..token import Token
88

99
if TYPE_CHECKING:
1010
from markdown_it.main import MarkdownIt

markdown_it/rules_block/table.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
# GFM table, https://github.github.com/gfm/#tables-extension-
22
import re
33

4+
from ..common.utils import charCodeAt, isSpace
45
from .state_block import StateBlock
5-
from ..common.utils import isSpace, charCodeAt
6-
76

87
headerLineRe = re.compile(r"^:?-+:?$")
98
enclosingPipesRe = re.compile(r"^\||\|$")

markdown_it/rules_core/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
"linkify",
99
)
1010

11-
from .state_core import StateCore
12-
from .normalize import normalize
1311
from .block import block
1412
from .inline import inline
13+
from .linkify import linkify
14+
from .normalize import normalize
1515
from .replacements import replace
1616
from .smartquotes import smartquotes
17-
from .linkify import linkify
17+
from .state_core import StateCore

markdown_it/rules_core/linkify.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import re
22

33
from ..common.utils import arrayReplaceAt
4-
from .state_core import StateCore
54
from ..token import Token
6-
5+
from .state_core import StateCore
76

87
LINK_OPEN_RE = re.compile(r"^<a[>\s]", flags=re.IGNORECASE)
98
LINK_CLOSE_RE = re.compile(r"^</a\s*>", flags=re.IGNORECASE)

markdown_it/rules_core/normalize.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
from .state_core import StateCore
55

6-
76
# https://spec.commonmark.org/0.29/#line-ending
87
NEWLINES_RE = re.compile(r"\r\n?|\n")
98
NULL_RE = re.compile(r"\0")

markdown_it/rules_core/replacements.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
import logging
2020
import re
2121

22-
from .state_core import StateCore
2322
from ..token import Token
23+
from .state_core import StateCore
2424

2525
LOGGER = logging.getLogger(__name__)
2626

markdown_it/rules_core/smartquotes.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@
55
import re
66
from typing import Any
77

8-
from .state_core import StateCore
9-
from ..common.utils import charCodeAt
10-
from ..common.utils import isWhiteSpace, isPunctChar, isMdAsciiPunct
8+
from ..common.utils import charCodeAt, isMdAsciiPunct, isPunctChar, isWhiteSpace
119
from ..token import Token
12-
10+
from .state_core import StateCore
1311

1412
QUOTE_TEST_RE = re.compile(r"['\"]")
1513
QUOTE_RE = re.compile(r"['\"]")

markdown_it/rules_core/state_core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
from collections.abc import MutableMapping
44
from typing import TYPE_CHECKING
55

6-
from ..token import Token
76
from ..ruler import StateBase
7+
from ..token import Token
88

99
if TYPE_CHECKING:
1010
from markdown_it import MarkdownIt

markdown_it/rules_inline/__init__.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,16 @@
1414
"html_inline",
1515
"strikethrough",
1616
)
17-
from .state_inline import StateInline
18-
from .text import text
19-
from .text_collapse import text_collapse
17+
from . import emphasis, strikethrough
18+
from .autolink import autolink
19+
from .backticks import backtick
2020
from .balance_pairs import link_pairs
21+
from .entity import entity
2122
from .escape import escape
22-
from .newline import newline
23-
from .backticks import backtick
24-
from . import emphasis
23+
from .html_inline import html_inline
2524
from .image import image
2625
from .link import link
27-
from .autolink import autolink
28-
from .entity import entity
29-
from .html_inline import html_inline
30-
from . import strikethrough
26+
from .newline import newline
27+
from .state_inline import StateInline
28+
from .text import text
29+
from .text_collapse import text_collapse

markdown_it/rules_inline/autolink.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Process autolinks '<protocol:...>'
22
import re
3+
34
from .state_inline import StateInline
45

56
EMAIL_RE = re.compile(

markdown_it/rules_inline/emphasis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Process *this* and _that_
22
#
33

4-
from .state_inline import StateInline, Delimiter
4+
from .state_inline import Delimiter, StateInline
55

66

77
def tokenize(state: StateInline, silent: bool):

markdown_it/rules_inline/entity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import re
33

44
from ..common.entities import entities
5-
from ..common.utils import isValidEntityCode, fromCodePoint
5+
from ..common.utils import fromCodePoint, isValidEntityCode
66
from .state_inline import StateInline
77

88
DIGITAL_RE = re.compile(r"^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));", re.IGNORECASE)

0 commit comments

Comments
 (0)