Skip to content

Commit c459cd2

Browse files
committed
Stricter type annotations for MkDocsConfig
No functional change, but users of modern MkDocs that also care about type annotations should be passing correct types by now.
1 parent d5bb15f commit c459cd2

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

mkdocs/plugins.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def on_serve(
153153

154154
# Global events
155155

156-
def on_config(self, config: MkDocsConfig) -> Config | None:
156+
def on_config(self, config: MkDocsConfig) -> MkDocsConfig | None:
157157
"""
158158
The `config` event is the first event called on build and is run immediately
159159
after the user configuration is loaded and validated. Any alterations to the

mkdocs/structure/files.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import shutil
99
import warnings
1010
from pathlib import PurePath
11-
from typing import TYPE_CHECKING, Any, Callable, Iterable, Iterator, Mapping, Sequence
11+
from typing import TYPE_CHECKING, Callable, Iterable, Iterator, Sequence
1212
from urllib.parse import quote as urlquote
1313

1414
import jinja2.environment
@@ -319,7 +319,7 @@ def is_css(self) -> bool:
319319
_default_exclude = pathspec.gitignore.GitIgnoreSpec.from_lines(['.*', '/templates/'])
320320

321321

322-
def _set_exclusions(files: Iterable[File], config: MkDocsConfig | Mapping[str, Any]) -> None:
322+
def _set_exclusions(files: Iterable[File], config: MkDocsConfig) -> None:
323323
"""Re-calculate which files are excluded, based on the patterns in the config."""
324324
exclude: pathspec.gitignore.GitIgnoreSpec | None = config.get('exclude_docs')
325325
exclude = _default_exclude + exclude if exclude else _default_exclude
@@ -335,7 +335,7 @@ def _set_exclusions(files: Iterable[File], config: MkDocsConfig | Mapping[str, A
335335
file.inclusion = InclusionLevel.Included
336336

337337

338-
def get_files(config: MkDocsConfig | Mapping[str, Any]) -> Files:
338+
def get_files(config: MkDocsConfig) -> Files:
339339
"""Walk the `docs_dir` and return a Files collection."""
340340
files: list[File] = []
341341
conflicting_files: list[tuple[File, File]] = []

mkdocs/structure/nav.py

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

33
import logging
4-
from typing import TYPE_CHECKING, Any, Iterator, Mapping, TypeVar
4+
from typing import TYPE_CHECKING, Iterator, TypeVar
55
from urllib.parse import urlsplit
66

77
from mkdocs.structure.pages import Page
@@ -145,7 +145,7 @@ def _indent_print(self, depth=0):
145145
return '{}{}'.format(' ' * depth, repr(self))
146146

147147

148-
def get_navigation(files: Files, config: MkDocsConfig | Mapping[str, Any]) -> Navigation:
148+
def get_navigation(files: Files, config: MkDocsConfig) -> Navigation:
149149
"""Build site navigation from config and files."""
150150
documentation_pages = files.documentation_pages()
151151
nav_config = config['nav'] or nest_paths(f.src_uri for f in documentation_pages)
@@ -193,7 +193,7 @@ def get_navigation(files: Files, config: MkDocsConfig | Mapping[str, Any]) -> Na
193193
return Navigation(items, pages)
194194

195195

196-
def _data_to_navigation(data, files: Files, config: MkDocsConfig | Mapping[str, Any]):
196+
def _data_to_navigation(data, files: Files, config: MkDocsConfig):
197197
if isinstance(data, dict):
198198
return [
199199
_data_to_navigation((key, value), files, config)

0 commit comments

Comments
 (0)