diff --git a/mkdocs/__main__.py b/mkdocs/__main__.py index a2f7594c..ec8696c7 100644 --- a/mkdocs/__main__.py +++ b/mkdocs/__main__.py @@ -36,7 +36,7 @@ def _showwarning(message, category, filename, lineno, file=None, line=None): stack = [frame for frame in traceback.extract_stack() if frame.line][-4:-2] # Make sure the actual affected file's name is still present (the case of syntax warning): if not any(frame.filename == filename for frame in stack): - stack = stack[-1:] + [traceback.FrameSummary(filename, lineno, '')] + stack = [*stack[-1:], traceback.FrameSummary(filename, lineno, '')] tb = ''.join(traceback.format_list(stack)) except Exception: diff --git a/mkdocs/config/base.py b/mkdocs/config/base.py index d21b42ab..e75a9aeb 100644 --- a/mkdocs/config/base.py +++ b/mkdocs/config/base.py @@ -86,12 +86,10 @@ def __set_name__(self, owner, name): self._name = name @overload - def __get__(self, obj: Config, type=None) -> T: - ... + def __get__(self, obj: Config, type=None) -> T: ... @overload - def __get__(self, obj, type=None) -> BaseConfigOption: - ... + def __get__(self, obj, type=None) -> BaseConfigOption: ... def __get__(self, obj, type=None): if not isinstance(obj, Config): diff --git a/mkdocs/config/config_options.py b/mkdocs/config/config_options.py index 2d08b92e..7e3a7a6c 100644 --- a/mkdocs/config/config_options.py +++ b/mkdocs/config/config_options.py @@ -155,12 +155,10 @@ class OptionallyRequired(Generic[T], BaseConfigOption[T]): """ @overload - def __init__(self, default=None): - ... + def __init__(self, default=None): ... @overload - def __init__(self, default=None, *, required: bool): - ... + def __init__(self, default=None, *, required: bool): ... def __init__(self, default=None, required=None): super().__init__() @@ -308,12 +306,10 @@ class ConfigItems(ListOfItems[LegacyConfig]): """ @overload - def __init__(self, *config_options: PlainConfigSchemaItem): - ... + def __init__(self, *config_options: PlainConfigSchemaItem): ... @overload - def __init__(self, *config_options: PlainConfigSchemaItem, required: bool): - ... + def __init__(self, *config_options: PlainConfigSchemaItem, required: bool): ... def __init__(self, *config_options: PlainConfigSchemaItem, required=None) -> None: super().__init__(SubConfig(*config_options), default=[]) @@ -329,12 +325,10 @@ class Type(Generic[T], OptionallyRequired[T]): """ @overload - def __init__(self, type_: type[T], /, length: int | None = None, **kwargs): - ... + def __init__(self, type_: type[T], /, length: int | None = None, **kwargs): ... @overload - def __init__(self, type_: tuple[type[T], ...], /, length: int | None = None, **kwargs): - ... + def __init__(self, type_: tuple[type[T], ...], /, length: int | None = None, **kwargs): ... def __init__(self, type_, /, length=None, **kwargs) -> None: super().__init__(**kwargs) @@ -498,12 +492,10 @@ class URL(OptionallyRequired[str]): """ @overload - def __init__(self, default=None, *, is_dir: bool = False): - ... + def __init__(self, default=None, *, is_dir: bool = False): ... @overload - def __init__(self, default=None, *, required: bool, is_dir: bool = False): - ... + def __init__(self, default=None, *, required: bool, is_dir: bool = False): ... def __init__(self, default=None, required=None, is_dir: bool = False) -> None: self.is_dir = is_dir @@ -760,12 +752,10 @@ class ListOfPaths(ListOfItems[str]): """ @overload - def __init__(self, default=[]): - ... + def __init__(self, default=[]): ... @overload - def __init__(self, default=[], *, required: bool): - ... + def __init__(self, default=[], *, required: bool): ... def __init__(self, default=[], required=None) -> None: super().__init__(FilesystemObject(exists=True), default) diff --git a/mkdocs/plugins.py b/mkdocs/plugins.py index f3dcb996..9c06e9a1 100644 --- a/mkdocs/plugins.py +++ b/mkdocs/plugins.py @@ -541,12 +541,10 @@ def __setitem__(self, key: str, value: BasePlugin) -> None: self._register_event(event_name[3:], method, plugin_name=key) @overload - def run_event(self, name: str, **kwargs) -> Any: - ... + def run_event(self, name: str, **kwargs) -> Any: ... @overload - def run_event(self, name: str, item: T, **kwargs) -> T: - ... + def run_event(self, name: str, item: T, **kwargs) -> T: ... def run_event(self, name: str, item=None, **kwargs): """ diff --git a/mkdocs/structure/__init__.py b/mkdocs/structure/__init__.py index c99b6575..64a890c9 100644 --- a/mkdocs/structure/__init__.py +++ b/mkdocs/structure/__init__.py @@ -11,8 +11,7 @@ class StructureItem(metaclass=abc.ABCMeta): """An item in MkDocs structure - see concrete subclasses Section, Page or Link.""" @abc.abstractmethod - def __init__(self): - ... + def __init__(self): ... parent: Section | None = None """The immediate parent of the item in the site navigation. `None` if it's at the top level.""" diff --git a/mkdocs/structure/nav.py b/mkdocs/structure/nav.py index 21815fe6..756f6333 100644 --- a/mkdocs/structure/nav.py +++ b/mkdocs/structure/nav.py @@ -188,16 +188,20 @@ def get_navigation(files: Files, config: MkDocsConfig) -> Navigation: def _data_to_navigation(data, files: Files, config: MkDocsConfig): if isinstance(data, dict): return [ - _data_to_navigation((key, value), files, config) - if isinstance(value, str) - else Section(title=key, children=_data_to_navigation(value, files, config)) + ( + _data_to_navigation((key, value), files, config) + if isinstance(value, str) + else Section(title=key, children=_data_to_navigation(value, files, config)) + ) for key, value in data.items() ] elif isinstance(data, list): return [ - _data_to_navigation(item, files, config)[0] - if isinstance(item, dict) and len(item) == 1 - else _data_to_navigation(item, files, config) + ( + _data_to_navigation(item, files, config)[0] + if isinstance(item, dict) and len(item) == 1 + else _data_to_navigation(item, files, config) + ) for item in data ] title, path = data if isinstance(data, tuple) else (None, data) diff --git a/mkdocs/structure/toc.py b/mkdocs/structure/toc.py index 7b4870bc..c2941bfa 100644 --- a/mkdocs/structure/toc.py +++ b/mkdocs/structure/toc.py @@ -5,6 +5,7 @@ generate a list of dicts for each toc item, and then store it as AnchorLinks to maintain compatibility with older versions of MkDocs. """ + from __future__ import annotations from typing import Iterable, Iterator, TypedDict diff --git a/mkdocs/tests/integration.py b/mkdocs/tests/integration.py index a992cac6..9b2ec1fa 100644 --- a/mkdocs/tests/integration.py +++ b/mkdocs/tests/integration.py @@ -14,7 +14,6 @@ - Build documentation other than just MkDocs as it is relatively simple. """ - import logging import os import subprocess diff --git a/mkdocs/utils/__init__.py b/mkdocs/utils/__init__.py index b53d37e2..42caca8e 100644 --- a/mkdocs/utils/__init__.py +++ b/mkdocs/utils/__init__.py @@ -4,6 +4,7 @@ Nothing in this module should have an knowledge of config or the layout and structure of the site and pages in the site. """ + from __future__ import annotations import functools diff --git a/mkdocs/utils/meta.py b/mkdocs/utils/meta.py index aa9e8980..174adb20 100644 --- a/mkdocs/utils/meta.py +++ b/mkdocs/utils/meta.py @@ -32,6 +32,7 @@ Extracts, parses and transforms MultiMarkdown style data from documents. """ + from __future__ import annotations import re diff --git a/pyproject.toml b/pyproject.toml index bacfbaa0..82b49dde 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,21 +55,21 @@ i18n = [ "babel >=2.9.0", ] min-versions = [ - "click ==7.0", - "Jinja2 ==2.11.1", - "markupsafe ==2.0.1", - "Markdown ==3.3.6", - "PyYAML ==5.1", - "watchdog ==2.0", - "ghp-import ==1.0", - "pyyaml_env_tag ==0.1", + "click ==8.1.8", + "Jinja2 ==3.1.6", + "markupsafe ==3.0.3", + "Markdown ==3.9", + "PyYAML ==6.0.3", + "watchdog ==6.0.0", + "ghp-import ==2.1.0", + "pyyaml_env_tag ==1.1", "importlib-metadata ==4.4; python_version < '3.10'", - "packaging ==20.5", + "packaging ==26.1", "mergedeep ==1.3.4", - "pathspec ==0.11.1", - "mkdocs-get-deps ==0.2.0", - "colorama ==0.4; platform_system == 'Windows'", - "babel ==2.9.0", + "pathspec ==1.0.4", + "mkdocs-get-deps ==0.2.2", + "colorama ==0.4.6; platform_system == 'Windows'", + "babel ==2.18.0", ] [project.urls] @@ -218,22 +218,22 @@ skip-string-normalization = true profile = "black" line_length = 100 -[tool.ruff] +[tool.ruff.lint] select = [ "F", "W", "E", "UP", "YTT", "C4", "DTZ", "FA", "ISC", "PIE", "T20", "RSE", "TCH", "B002", "B003", "B005", "B007", "B009", "B012", "B013", "B014", "B015", "B018", "B020", "B021", "B023", "B026", "B033", "B034", "B905", "COM818", "D200", "D201", "D202", "D204", "D207", "D208", "D209", "D210", "D211", "D213", "D214", "D300", "D301", "D400", "D402", "D403", "D405", "D412", "D414", "D415", "D416", "D417", "D419", "PERF101", - "PGH002", "PGH004", "PGH005", + "PGH004", "PGH005", "FLY002", "PLC", "PLE", "PLR0124", "PLR0133", "PLR0206", "PLR0402", "PLR1701", "PLR1722", "PLW0120", "PLW0127", "PLW0129", "PLW0131", "PLW0406", "PLW0602", "PLW0603", "PLW0711", "RUF001", "RUF005", "RUF007", "RUF010", "RUF013", "RUF100", "RUF200", "SIM101", "SIM107", "SIM201", "SIM202", "SIM208", "SIM210", "SIM211", "SIM300", "SIM401", "SIM910", ] -ignore = ["E501", "E731"] +ignore = ["E501", "E731", "PLC0415"] -[tool.ruff.flake8-comprehensions] +[tool.ruff.lint.flake8-comprehensions] allow-dict-calls-with-keyword-arguments = true [tool.mypy] diff --git a/requirements/requirements-docs.txt b/requirements/requirements-docs.txt index 87133cae..670f9bf0 100644 --- a/requirements/requirements-docs.txt +++ b/requirements/requirements-docs.txt @@ -27,7 +27,7 @@ # - watchdog>=2.0 # -click==8.1.7 +click==8.1.8 # via # hatch.envs.docs # mkdocs @@ -39,14 +39,14 @@ ghp-import==2.1.0 # via # hatch.envs.docs # mkdocs -griffe==0.38.0 +griffe==1.14.0 # via mkdocstrings-python -jinja2==3.1.2 +jinja2==3.1.6 # via # hatch.envs.docs # mkdocs # mkdocstrings -markdown==3.5.1 +markdown==3.9 # via # hatch.envs.docs # markdown-callouts @@ -56,79 +56,79 @@ markdown==3.5.1 # mkdocs-click # mkdocstrings # pymdown-extensions -markdown-callouts==0.3.0 +markdown-callouts==0.4.0 # via hatch.envs.docs -markupsafe==2.1.3 +markupsafe==3.0.3 # via # hatch.envs.docs # jinja2 # mkdocs # mkdocstrings -mdx-gh-links==0.3.1 +mdx-gh-links==0.4 # via hatch.envs.docs mergedeep==1.3.4 # via # hatch.envs.docs # mkdocs # mkdocs-get-deps -mkdocs==1.5.3 +mkdocs==1.6.1 # via # hatch.envs.docs # mkdocs-autorefs # mkdocs-literate-nav # mkdocs-redirects # mkdocstrings -mkdocs-autorefs==0.5.0 +mkdocs-autorefs==1.4.4 # via # hatch.envs.docs # mkdocstrings -mkdocs-click==0.8.1 +mkdocs-click==0.9.0 # via hatch.envs.docs -mkdocs-get-deps==0.2.0 +mkdocs-get-deps==0.2.2 # via hatch.envs.docs -mkdocs-literate-nav==0.6.1 +mkdocs-literate-nav==0.6.3 # via hatch.envs.docs -mkdocs-redirects==1.2.1 +mkdocs-redirects==1.2.2 # via hatch.envs.docs -mkdocstrings==0.24.0 +mkdocstrings==0.30.1 # via # hatch.envs.docs # mkdocstrings-python -mkdocstrings-python==1.7.5 +mkdocstrings-python==1.18.2 # via hatch.envs.docs -packaging==23.2 +packaging==26.1 # via # hatch.envs.docs # mkdocs -pathspec==0.11.2 +pathspec==1.0.4 # via # hatch.envs.docs # mkdocs -platformdirs==4.0.0 +platformdirs==4.4.0 # via # mkdocs # mkdocs-get-deps # mkdocstrings -pymdown-extensions==10.4 +pymdown-extensions==10.21.2 # via # hatch.envs.docs # mkdocstrings -python-dateutil==2.8.2 +python-dateutil==2.9.0.post0 # via ghp-import -pyyaml==6.0.1 +pyyaml==6.0.3 # via # hatch.envs.docs # mkdocs # mkdocs-get-deps # pymdown-extensions # pyyaml-env-tag -pyyaml-env-tag==0.1 +pyyaml-env-tag==1.1 # via # hatch.envs.docs # mkdocs -six==1.16.0 +six==1.17.0 # via python-dateutil -watchdog==3.0.0 +watchdog==6.0.0 # via # hatch.envs.docs # mkdocs diff --git a/requirements/requirements-style.txt b/requirements/requirements-style.txt index 596540f5..a022836f 100644 --- a/requirements/requirements-style.txt +++ b/requirements/requirements-style.txt @@ -6,19 +6,19 @@ # - ruff # -black==23.12.1 +black==25.11.0 # via hatch.envs.style -click==8.1.7 +click==8.1.8 # via black -isort==5.13.2 +isort==6.1.0 # via hatch.envs.style -mypy-extensions==1.0.0 +mypy-extensions==1.1.0 # via black -packaging==23.2 +packaging==26.1 # via black -pathspec==0.12.1 +pathspec==1.0.4 # via black -platformdirs==4.1.0 +platformdirs==4.4.0 # via black -ruff==0.1.14 +ruff==0.15.11 # via hatch.envs.style