Skip to content

Commit 418e770

Browse files
committed
style: Format (for Python 3.9)
1 parent ee3eaad commit 418e770

File tree

3 files changed

+10
-19
lines changed

3 files changed

+10
-19
lines changed

src/mkdocs_autorefs/plugin.py

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
import contextlib
1616
import functools
1717
import logging
18-
import sys
19-
from typing import TYPE_CHECKING, Any, Callable, Sequence
18+
from pathlib import PurePosixPath as URL # noqa: N814
19+
from typing import TYPE_CHECKING, Any, Callable
2020
from urllib.parse import urlsplit
2121

2222
from mkdocs.config.base import Config
@@ -27,6 +27,8 @@
2727
from mkdocs_autorefs.references import AutorefsExtension, fix_refs, relative_url
2828

2929
if TYPE_CHECKING:
30+
from collections.abc import Sequence
31+
3032
from mkdocs.config.defaults import MkDocsConfig
3133
from mkdocs.structure.pages import Page
3234
from mkdocs.structure.toc import AnchorLink
@@ -40,21 +42,6 @@
4042
log = logging.getLogger(f"mkdocs.plugins.{__name__}") # type: ignore[assignment]
4143

4244

43-
# YORE: EOL 3.8: Remove block.
44-
if sys.version_info < (3, 9):
45-
from pathlib import PurePosixPath
46-
47-
class URL(PurePosixPath): # noqa: D101
48-
def is_relative_to(self, *args: Any) -> bool: # noqa: D102
49-
try:
50-
self.relative_to(*args)
51-
except ValueError:
52-
return False
53-
return True
54-
else:
55-
from pathlib import PurePosixPath as URL # noqa: N814
56-
57-
5845
class AutorefsConfig(Config):
5946
"""Configuration options for the `autorefs` plugin."""
6047

src/mkdocs_autorefs/references.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from functools import lru_cache
1111
from html import escape, unescape
1212
from html.parser import HTMLParser
13-
from typing import TYPE_CHECKING, Any, Callable, ClassVar, Match
13+
from typing import TYPE_CHECKING, Any, Callable, ClassVar
1414
from urllib.parse import urlsplit
1515
from xml.etree.ElementTree import Element
1616

@@ -23,6 +23,7 @@
2323

2424
if TYPE_CHECKING:
2525
from pathlib import Path
26+
from re import Match
2627

2728
from markdown import Markdown
2829

tests/test_references.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@
33
from __future__ import annotations
44

55
from textwrap import dedent
6-
from typing import Mapping
6+
from typing import TYPE_CHECKING
77

88
import markdown
99
import pytest
1010

1111
from mkdocs_autorefs.plugin import AutorefsPlugin
1212
from mkdocs_autorefs.references import AutorefsExtension, AutorefsHookInterface, fix_refs, relative_url
1313

14+
if TYPE_CHECKING:
15+
from collections.abc import Mapping
16+
1417

1518
@pytest.mark.parametrize(
1619
("current_url", "to_url", "href_url"),

0 commit comments

Comments
 (0)