From 6d046954bb8fe0d81d09e99717e4fac4290ec432 Mon Sep 17 00:00:00 2001 From: Hsiaoming Yang Date: Thu, 24 Oct 2024 17:53:07 +0900 Subject: [PATCH] fix: cleanup unused imports --- pyproject.toml | 3 +++ src/mistune/__init__.py | 2 +- src/mistune/block_parser.py | 2 +- src/mistune/core.py | 2 -- src/mistune/directives/admonition.py | 2 +- src/mistune/directives/toc.py | 1 - src/mistune/inline_parser.py | 9 --------- src/mistune/list_parser.py | 1 - src/mistune/plugins/abbr.py | 4 ++-- src/mistune/plugins/def_list.py | 5 ++--- src/mistune/plugins/footnotes.py | 4 ++-- src/mistune/plugins/formatting.py | 5 ++--- src/mistune/plugins/math.py | 7 ++++--- src/mistune/plugins/ruby.py | 5 ++--- src/mistune/plugins/speedup.py | 4 ++-- src/mistune/plugins/spoiler.py | 4 ++-- src/mistune/plugins/table.py | 4 +--- src/mistune/plugins/task_lists.py | 6 ++---- src/mistune/plugins/url.py | 6 +++--- 19 files changed, 30 insertions(+), 46 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 38bd7ce..5a8247a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,6 +46,9 @@ where = ["src"] [tool.setuptools.package-data] mistune = ["py.typed"] +[tool.ruff] +line-length = 120 + [tool.pytest.ini_options] pythonpath = ["src", "."] testpaths = ["tests"] diff --git a/src/mistune/__init__.py b/src/mistune/__init__.py index 9c22632..9448eae 100644 --- a/src/mistune/__init__.py +++ b/src/mistune/__init__.py @@ -8,7 +8,7 @@ Documentation: https://mistune.lepture.com/ """ -from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, Union +from typing import Any, Dict, Iterable, List, Optional, Tuple, Union from typing_extensions import Literal diff --git a/src/mistune/block_parser.py b/src/mistune/block_parser.py index de37246..8e43bb6 100644 --- a/src/mistune/block_parser.py +++ b/src/mistune/block_parser.py @@ -1,5 +1,5 @@ import re -from typing import Optional, List, Tuple, Match, Type, Pattern +from typing import Optional, List, Tuple, Match, Pattern from .util import ( unikey, escape_url, diff --git a/src/mistune/core.py b/src/mistune/core.py index 75715fa..05a2d20 100644 --- a/src/mistune/core.py +++ b/src/mistune/core.py @@ -1,5 +1,4 @@ import re -from collections.abc import Generator from typing import ( Any, Callable, @@ -12,7 +11,6 @@ MutableMapping, Optional, Pattern, - Set, Type, TypeVar, Union, diff --git a/src/mistune/directives/admonition.py b/src/mistune/directives/admonition.py index f0d65e3..5ecdd31 100644 --- a/src/mistune/directives/admonition.py +++ b/src/mistune/directives/admonition.py @@ -1,4 +1,4 @@ -from typing import TYPE_CHECKING, Any, Dict, List, Match, Optional +from typing import TYPE_CHECKING, Any, Dict, Match from ._base import BaseDirective, DirectivePlugin diff --git a/src/mistune/directives/toc.py b/src/mistune/directives/toc.py index 7945dbc..45a13d7 100644 --- a/src/mistune/directives/toc.py +++ b/src/mistune/directives/toc.py @@ -96,7 +96,6 @@ def render_html_toc( ) -> str: if not title: title = 'Table of Contents' - toc = attrs['toc'] content = render_toc_ul(attrs['toc']) html = '
[\s\S]+?)\n\$\$[ \t]*$' INLINE_MATH_PATTERN = r'\$(?!\s)(?P.+?)(?!\s)\$' diff --git a/src/mistune/plugins/ruby.py b/src/mistune/plugins/ruby.py index 5081346..6cc3111 100644 --- a/src/mistune/plugins/ruby.py +++ b/src/mistune/plugins/ruby.py @@ -1,12 +1,11 @@ import re -from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Match, Optional +from typing import TYPE_CHECKING, Any, Dict, List, Match, Optional from ..helpers import parse_link, parse_link_label from ..util import unikey if TYPE_CHECKING: - from ..block_parser import BlockParser - from ..core import BaseRenderer, BlockState, InlineState, Parser + from ..core import BaseRenderer, InlineState from ..inline_parser import InlineParser from ..markdown import Markdown diff --git a/src/mistune/plugins/speedup.py b/src/mistune/plugins/speedup.py index 42f9444..d549c59 100644 --- a/src/mistune/plugins/speedup.py +++ b/src/mistune/plugins/speedup.py @@ -1,10 +1,10 @@ import re import string -from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Match, Optional +from typing import TYPE_CHECKING, Match if TYPE_CHECKING: from ..block_parser import BlockParser - from ..core import BaseRenderer, BlockState, InlineState, Parser + from ..core import BlockState, InlineState from ..inline_parser import InlineParser from ..markdown import Markdown diff --git a/src/mistune/plugins/spoiler.py b/src/mistune/plugins/spoiler.py index 30371bc..95e6da5 100644 --- a/src/mistune/plugins/spoiler.py +++ b/src/mistune/plugins/spoiler.py @@ -1,9 +1,9 @@ import re -from typing import TYPE_CHECKING, Match, Optional +from typing import TYPE_CHECKING, Match if TYPE_CHECKING: from ..block_parser import BlockParser - from ..core import BaseRenderer, BlockState, InlineState, Parser + from ..core import BaseRenderer, BlockState, InlineState from ..inline_parser import InlineParser from ..markdown import Markdown diff --git a/src/mistune/plugins/table.py b/src/mistune/plugins/table.py index d47f0ac..39e81f9 100644 --- a/src/mistune/plugins/table.py +++ b/src/mistune/plugins/table.py @@ -3,7 +3,6 @@ TYPE_CHECKING, Any, Dict, - Iterable, List, Match, Optional, @@ -15,8 +14,7 @@ if TYPE_CHECKING: from ..block_parser import BlockParser - from ..core import BaseRenderer, BlockState, InlineState, Parser - from ..inline_parser import InlineParser + from ..core import BaseRenderer, BlockState from ..markdown import Markdown # https://michelf.ca/projects/php-markdown/extra/#table diff --git a/src/mistune/plugins/task_lists.py b/src/mistune/plugins/task_lists.py index eb7a258..840088f 100644 --- a/src/mistune/plugins/task_lists.py +++ b/src/mistune/plugins/task_lists.py @@ -1,10 +1,8 @@ import re -from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Match, Optional +from typing import TYPE_CHECKING, Any, Dict, Iterable if TYPE_CHECKING: - from ..block_parser import BlockParser - from ..core import BaseRenderer, BlockState, InlineState, Parser - from ..inline_parser import InlineParser + from ..core import BaseRenderer, BlockState from ..markdown import Markdown __all__ = ['task_lists'] diff --git a/src/mistune/plugins/url.py b/src/mistune/plugins/url.py index 7f68d91..9c82912 100644 --- a/src/mistune/plugins/url.py +++ b/src/mistune/plugins/url.py @@ -1,12 +1,12 @@ -from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Match, Optional +from typing import TYPE_CHECKING, Match from ..util import escape_url if TYPE_CHECKING: - from ..block_parser import BlockParser - from ..core import BaseRenderer, BlockState, InlineState, Parser + from ..core import InlineState from ..inline_parser import InlineParser from ..markdown import Markdown + __all__ = ['url'] URL_LINK_PATTERN = r'''https?:\/\/[^\s<]+[^<.,:;"')\]\s]'''