Skip to content

Commit

Permalink
Stricter type annotations for MkDocsConfig
Browse files Browse the repository at this point in the history
No functional change, but users of modern MkDocs that also care about type annotations should be passing correct types by now.
  • Loading branch information
oprypin committed Jun 18, 2023
1 parent d5bb15f commit c459cd2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion mkdocs/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def on_serve(

# Global events

def on_config(self, config: MkDocsConfig) -> Config | None:
def on_config(self, config: MkDocsConfig) -> MkDocsConfig | None:
"""
The `config` event is the first event called on build and is run immediately
after the user configuration is loaded and validated. Any alterations to the
Expand Down
6 changes: 3 additions & 3 deletions mkdocs/structure/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import shutil
import warnings
from pathlib import PurePath
from typing import TYPE_CHECKING, Any, Callable, Iterable, Iterator, Mapping, Sequence
from typing import TYPE_CHECKING, Callable, Iterable, Iterator, Sequence
from urllib.parse import quote as urlquote

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


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


def get_files(config: MkDocsConfig | Mapping[str, Any]) -> Files:
def get_files(config: MkDocsConfig) -> Files:
"""Walk the `docs_dir` and return a Files collection."""
files: list[File] = []
conflicting_files: list[tuple[File, File]] = []
Expand Down
6 changes: 3 additions & 3 deletions mkdocs/structure/nav.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

import logging
from typing import TYPE_CHECKING, Any, Iterator, Mapping, TypeVar
from typing import TYPE_CHECKING, Iterator, TypeVar
from urllib.parse import urlsplit

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


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


def _data_to_navigation(data, files: Files, config: MkDocsConfig | Mapping[str, Any]):
def _data_to_navigation(data, files: Files, config: MkDocsConfig):
if isinstance(data, dict):
return [
_data_to_navigation((key, value), files, config)
Expand Down

0 comments on commit c459cd2

Please sign in to comment.