Skip to content

Commit 502e0c7

Browse files
committed
Template upgrade
1 parent ea5bc39 commit 502e0c7

13 files changed

Lines changed: 77 additions & 77 deletions

File tree

.github/workflows/autofix.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ jobs:
2626
git diff --color --exit-code
2727
- name: Apply automatic fixes using pre-commit-ci-lite
2828
if: failure() && github.event_name == 'pull_request'
29-
uses: pre-commit-ci/lite-action@v1.0.1
29+
uses: pre-commit-ci/lite-action@5d6cc0eb514c891a40562a58a8e71576c5c7fb43 # v1.1.0

.github/workflows/ci.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@ jobs:
1313
fail-fast: false
1414
matrix:
1515
include:
16-
- python: '^3.12'
16+
- python: '^3.13'
1717
os: ubuntu-latest
18-
- python: '3.12'
18+
- python: '3.13'
1919
os: macos-latest
20-
- python: '3.11'
20+
- python: '3.12'
2121
os: windows-latest
22-
- python: '3.10'
22+
- python: '3.11'
2323
os: ubuntu-latest
24-
- python: '3.9'
24+
- python: '3.10'
2525
os: macos-latest
26-
- python: '3.8'
26+
- python: '3.9'
2727
os: windows-latest
28-
- python: '3.8'
28+
- python: '3.9'
2929
os: ubuntu-latest
3030
versions: minimal
3131
runs-on: ${{matrix.os}}

.github/workflows/deploy-docs.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ jobs:
1313
- name: Install Python
1414
uses: actions/setup-python@v5
1515
with:
16-
python-version: '3.11'
16+
python-version: '3.12'
1717
- name: Install dependencies
1818
run: pip install --no-deps -r requirements/requirements-docs.txt
1919
- name: Build site
2020
run: mkdocs build --strict
2121
- name: Upload to GitHub Pages
22-
uses: actions/upload-pages-artifact@v2
22+
uses: actions/upload-pages-artifact@v3
2323
with:
2424
path: site
2525
deploy:
@@ -32,7 +32,7 @@ jobs:
3232
steps:
3333
- name: Deploy to GitHub Pages
3434
id: deployment
35-
uses: actions/deploy-pages@v2
35+
uses: actions/deploy-pages@v4
3636
environment:
3737
name: github-pages
3838
url: ${{ steps.deployment.outputs.page_url }}

.tools/copier-answers.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
_commit: 0903da199
1+
_commit: 9d045b25c
22
_src_path: gh:oprypin/py-project-template
33
copyright_date: '2020'
44
mkdocs: true

mkdocstrings_handlers/crystal/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

3-
from typing import Any, Mapping, Sequence
3+
from collections.abc import Mapping, Sequence
4+
from typing import Any
45

56
from mkdocstrings.handlers.base import BaseHandler
67

mkdocstrings_handlers/crystal/collector.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,9 @@
99
import re
1010
import shlex
1111
import subprocess
12+
from collections.abc import Iterable, Iterator, Mapping, Sequence
1213
from functools import cached_property
13-
from typing import (
14-
TYPE_CHECKING,
15-
Any,
16-
Callable,
17-
Iterable,
18-
Iterator,
19-
Mapping,
20-
Sequence,
21-
TypeVar,
22-
cast,
23-
)
14+
from typing import TYPE_CHECKING, Any, Callable, TypeVar, cast
2415

2516
from mkdocstrings.handlers.base import BaseHandler, CollectionError
2617

@@ -87,7 +78,7 @@ def root(self) -> DocRoot:
8778
return module
8879
finally:
8980
if self._proc.returncode:
90-
args = cast(Sequence[str], self._proc.args)
81+
args = cast("Sequence[str]", self._proc.args)
9182
cmd = " ".join(shlex.quote(arg) for arg in args)
9283
raise PluginError(f"Command `{cmd}` exited with status {self._proc.returncode}")
9384

@@ -130,7 +121,7 @@ def shard_version(self) -> str:
130121
return self._shard_version(os.path.dirname(self.src_path))
131122

132123
@classmethod
133-
@functools.lru_cache(maxsize=None)
124+
@functools.cache
134125
def _shard_version(cls, path: str) -> str:
135126
file_path = _find_above(path, "shard.yml")
136127
with open(file_path, "rb") as f:
@@ -234,7 +225,7 @@ def _get_locations(cls, obj: DocItem) -> Sequence[str]:
234225
@classmethod
235226
def _filter(
236227
cls,
237-
filters: bool | Sequence[str],
228+
filters: Sequence[str] | bool, # noqa: FBT001
238229
mapp: DocMapping[D],
239230
getter: Callable[[D], Sequence[str]],
240231
) -> DocMapping[D]:

mkdocstrings_handlers/crystal/crystal_html.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
import collections
44
import html.parser
55
import io
6-
from typing import Callable, Iterable, Sequence, Tuple
6+
from collections.abc import Iterable, Sequence
7+
from typing import Callable
78

89
from markupsafe import Markup, escape
910

10-
LinkToken = Tuple[int, int, str]
11+
LinkToken = tuple[int, int, str]
1112

1213

1314
class TextWithLinks(collections.UserString):
@@ -40,7 +41,7 @@ def linkify_highlighted_html(
4041
) -> str:
4142
pygments_parser = _PygmentsHTMLHandler(html_tokens, make_link)
4243
pygments_parser.feed(pygments_html)
43-
return Markup(pygments_parser.html.getvalue())
44+
return Markup(pygments_parser.html.getvalue()) # noqa: RUF035
4445

4546

4647
class _CrystalHTMLHandler(html.parser.HTMLParser):
@@ -65,8 +66,7 @@ def handle_data(self, data):
6566

6667
@classmethod
6768
def link_to_path(cls, href):
68-
if href.endswith(".html"):
69-
href = href[:-5]
69+
href = href.removesuffix(".html")
7070
while href.startswith("../"):
7171
href = href[3:]
7272
return href.replace("/", "::")
@@ -99,7 +99,7 @@ def handle_endtag(self, tag):
9999
if tag == "span" and self.inlink is not None:
100100
if self.token and self.token[1] <= self.pos:
101101
self.html.seek(self.inlink)
102-
subhtml = Markup(self.html.read())
102+
subhtml = Markup(self.html.read()) # noqa: RUF035
103103
subhtml = self.make_link(self.token[2], subhtml)
104104
self.token = next(self.tokens, None)
105105

mkdocstrings_handlers/crystal/deduplicate_toc.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ def run(self, root: etree.Element):
3333

3434

3535
class DeduplicateTocExtension(Extension):
36-
def extendMarkdown(self, md: Markdown) -> None:
36+
@classmethod
37+
def extendMarkdown(cls, md: Markdown) -> None:
3738
md.treeprocessors.register(
3839
_TocDeduplicatingTreeprocessor(md), "mkdocstrings_crystal_deduplicate_toc", 4
3940
)

mkdocstrings_handlers/crystal/inventory.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
import itertools
44
import json
55
import posixpath
6-
from typing import IO, Iterator
6+
from collections.abc import Iterator
7+
from typing import IO
78

89
from .items import DocModule
910

mkdocstrings_handlers/crystal/items.py

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,21 @@
55
import contextlib
66
import dataclasses
77
import re
8+
from collections.abc import Iterator, Mapping, Sequence
89
from functools import cached_property
9-
from typing import (
10-
TYPE_CHECKING,
11-
Any,
12-
ClassVar,
13-
Generic,
14-
Iterator,
15-
Mapping,
16-
Sequence,
17-
TypeVar,
18-
overload,
19-
)
10+
from typing import TYPE_CHECKING, Any, ClassVar, Generic, TypeVar, overload
2011

2112
from mkdocstrings.handlers.base import CollectionError
2213

2314
from . import crystal_html
2415

2516
if TYPE_CHECKING:
17+
from typing_extensions import Self
18+
2619
from .collector import DocRoot
2720

2821

29-
class DocItem(metaclass=abc.ABCMeta):
22+
class DocItem(abc.ABC):
3023
"""A representation of a documentable item from Crystal language."""
3124

3225
_TEMPLATE: str
@@ -140,18 +133,16 @@ class DocType(DocItem):
140133
_TEMPLATE = "type.html"
141134

142135
@overload
143-
def __new__(cls: type[DocType], data: Mapping[str, Any], *args, **kwargs) -> DocType:
144-
...
136+
def __new__(cls, data: Mapping[str, Any], *args, **kwargs) -> Self: ...
145137

146138
@overload
147-
def __new__(cls, data: Mapping[str, Any] | None = None, *args, **kwargs) -> DocType:
148-
...
139+
def __new__(cls, data: Mapping[str, Any] | None = None, *args, **kwargs) -> Self: ...
149140

150-
def __new__(cls, data=None, *args, **kwargs) -> DocType:
141+
def __new__(cls, data=None, *args, **kwargs) -> Self:
151142
"""Based on Crystal's JSON, create an object of an appropriate subclass of DocType"""
152143
if cls is DocType:
153144
try:
154-
cls = _doc_type_mapping[data["kind"]]
145+
cls = _doc_type_mapping[data["kind"]] # type: ignore[assignment]
155146
except KeyError:
156147
raise TypeError(
157148
"DocType is abstract, and {kind!r} is not recognized".format_map(data)
@@ -431,10 +422,11 @@ class DocMapping(Generic[D]):
431422
search: Mapping[str, Any] = {}
432423
_empty: ClassVar[DocMapping]
433424

434-
def __new__(cls, items: Sequence[D]) -> DocMapping:
425+
def __new__(cls, items: Sequence[D]) -> Self:
435426
if not items:
427+
empty: Self
436428
try:
437-
empty = cls._empty
429+
empty = cls._empty # type: ignore[assignment]
438430
except AttributeError:
439431
cls._empty = empty = object.__new__(cls)
440432
return empty

0 commit comments

Comments
 (0)