Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pre-commit.ci] pre-commit autoupdate #859

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/docutils_setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
"""Script to convert package setup to myst-docutils."""

import sys

import tomlkit
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.11
rev: v0.3.4
hooks:
- id: ruff
args: [--fix]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
rev: v1.9.0
hooks:
- id: mypy
args: [--config-file=pyproject.toml]
Expand Down
1 change: 1 addition & 0 deletions myst_parser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
with bridges to [docutils](https://docutils.sourceforge.io/)
and [Sphinx](https://github.com/sphinx-doc/sphinx).
"""

__version__ = "2.0.0"


Expand Down
1 change: 1 addition & 0 deletions myst_parser/_compat.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Helpers for cross compatibility across dependency versions."""

from typing import Callable, Iterable

from docutils.nodes import Element
Expand Down
1 change: 1 addition & 0 deletions myst_parser/_docs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Code to use internally, for documentation."""

from __future__ import annotations

import contextlib
Expand Down
4 changes: 2 additions & 2 deletions myst_parser/config/dc_validators.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Validators for dataclasses, mirroring those of https://github.com/python-attrs/attrs."""

from __future__ import annotations

import dataclasses as dc
Expand Down Expand Up @@ -37,8 +38,7 @@ def validate_fields(inst: Any) -> None:
class ValidatorType(Protocol):
def __call__(
self, inst: Any, field: dc.Field, value: Any, suffix: str = ""
) -> None:
...
) -> None: ...


def any_(inst, field, value, suffix=""):
Expand Down
1 change: 1 addition & 0 deletions myst_parser/config/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""The configuration for the myst parser."""

import dataclasses as dc
from importlib import import_module
from typing import (
Expand Down
1 change: 1 addition & 0 deletions myst_parser/docutils_.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
.. include:: path/to/file.md
:parser: myst_parser.docutils_
"""

from myst_parser.parsers.docutils_ import Parser # noqa: F401
1 change: 1 addition & 0 deletions myst_parser/inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
This is adapted from the Sphinx inventory.py module.
We replicate it here, so that it can be used without Sphinx.
"""

from __future__ import annotations

import argparse
Expand Down
7 changes: 4 additions & 3 deletions myst_parser/mdit_to_docutils/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Convert Markdown-it tokens to docutils nodes."""

from __future__ import annotations

import inspect
Expand Down Expand Up @@ -260,9 +261,9 @@ def _render_finalise(self) -> None:
# save for later reference resolution
self.document.myst_slugs = self._heading_slugs
if self._heading_slugs and self.sphinx_env:
self.sphinx_env.metadata[self.sphinx_env.docname][
"myst_slugs"
] = self._heading_slugs
self.sphinx_env.metadata[self.sphinx_env.docname]["myst_slugs"] = (
self._heading_slugs
)

# log warnings for duplicate reference definitions
# "duplicate_refs": [{"href": "ijk", "label": "B", "map": [4, 5], "title": ""}],
Expand Down
1 change: 1 addition & 0 deletions myst_parser/mdit_to_docutils/html_to_nodes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Convert HTML to docutils nodes."""

from __future__ import annotations

import re
Expand Down
1 change: 1 addition & 0 deletions myst_parser/mdit_to_docutils/sphinx_.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Convert Markdown-it tokens to docutils nodes, including sphinx specific elements."""

from __future__ import annotations

import os
Expand Down
1 change: 1 addition & 0 deletions myst_parser/mdit_to_docutils/transforms.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Directives that can be applied to both Sphinx and docutils."""

from __future__ import annotations

import typing as t
Expand Down
5 changes: 2 additions & 3 deletions myst_parser/mocking.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""This module provides classes to Mock the core components of the docutils.RSTParser,
the key difference being that nested parsing treats the text as Markdown not rST.
"""

from __future__ import annotations

import os
Expand Down Expand Up @@ -393,9 +394,7 @@ def run(self) -> list[nodes.Element]:
if split_index < 0:
raise DirectiveError(
4,
'Directive "{}"; option "{}": text not found "{}".'.format(
self.name, split_on_type, split_on
),
f'Directive "{self.name}"; option "{split_on_type}": text not found "{split_on}".',
)
if split_on_type == "start-after":
startline += split_index + len(split_on)
Expand Down
1 change: 1 addition & 0 deletions myst_parser/parsers/directives.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
This is to allow for separation between the option block and content.

"""

from __future__ import annotations

import re
Expand Down
1 change: 1 addition & 0 deletions myst_parser/parsers/docutils_.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""MyST Markdown parser for docutils."""

from dataclasses import Field
from typing import (
Any,
Expand Down
1 change: 1 addition & 0 deletions myst_parser/parsers/mdit.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""This module holds the ``create_md_parser`` function,
which creates a parser from the config.
"""

from __future__ import annotations

from typing import Callable
Expand Down
17 changes: 9 additions & 8 deletions myst_parser/parsers/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
For a good description of multi-line YAML strings, see:
https://stackoverflow.com/a/21699210/5033292
"""

from __future__ import annotations

from dataclasses import dataclass, replace
Expand Down Expand Up @@ -65,7 +66,7 @@ def forward(self, length: int = 1) -> None:
):
self._line += 1
self._column = 0
elif ch != "\uFEFF":
elif ch != "\ufeff":
self._column += 1
length -= 1

Expand Down Expand Up @@ -259,7 +260,7 @@ def _scan_to_next_token(stream: StreamBuffer) -> None:
The byte order mark is also stripped,
if it's the first character in the stream.
"""
if stream.index == 0 and stream.peek() == "\uFEFF":
if stream.index == 0 and stream.peek() == "\ufeff":
stream.forward()
found = False
while not found:
Expand Down Expand Up @@ -636,17 +637,17 @@ def _scan_block_scalar_breaks(
"b": "\x08",
"t": "\x09",
"\t": "\x09",
"n": "\x0A",
"v": "\x0B",
"f": "\x0C",
"r": "\x0D",
"e": "\x1B",
"n": "\x0a",
"v": "\x0b",
"f": "\x0c",
"r": "\x0d",
"e": "\x1b",
" ": "\x20",
'"': '"',
"\\": "\\",
"/": "/",
"N": "\x85",
"_": "\xA0",
"_": "\xa0",
"L": "\u2028",
"P": "\u2029",
}
Expand Down
1 change: 1 addition & 0 deletions myst_parser/parsers/parse_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
(see https://html.spec.whatwg.org/multipage/syntax.html#optional-tags)

"""

from __future__ import annotations

import inspect
Expand Down
1 change: 1 addition & 0 deletions myst_parser/parsers/sphinx_.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""MyST Markdown parser for sphinx."""

from __future__ import annotations

from docutils import nodes
Expand Down
1 change: 1 addition & 0 deletions myst_parser/sphinx_.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
.. include:: path/to/file.md
:parser: myst_parser.sphinx_
"""

from myst_parser.parsers.sphinx_ import MystParser as Parser # noqa: F401
1 change: 1 addition & 0 deletions myst_parser/sphinx_ext/directives.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""MyST specific directives"""

from copy import copy
from typing import List, Tuple, cast

Expand Down
1 change: 1 addition & 0 deletions myst_parser/sphinx_ext/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""The setup for the sphinx extension."""

from typing import Any

from docutils import nodes
Expand Down
1 change: 1 addition & 0 deletions myst_parser/sphinx_ext/mathjax.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
and assigned an equation number

"""

from docutils import nodes
from sphinx.application import Sphinx
from sphinx.ext import mathjax
Expand Down
1 change: 1 addition & 0 deletions myst_parser/sphinx_ext/myst_refs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
This is applied to MyST type references only, such as ``[text](target)``,
and allows for nested syntax
"""

from __future__ import annotations

import re
Expand Down
1 change: 1 addition & 0 deletions myst_parser/warnings_.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Central handling of warnings for the myst extension."""

from __future__ import annotations

from enum import Enum
Expand Down
1 change: 1 addition & 0 deletions tests/test_commonmark/test_commonmark.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""In this module tests are run against the full test set,
provided by https://github.com/commonmark/CommonMark.git.
"""

import json
import os

Expand Down
1 change: 1 addition & 0 deletions tests/test_inventory.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test reading of inventory files."""

from pathlib import Path

import pytest
Expand Down
1 change: 1 addition & 0 deletions tests/test_renderers/test_error_reporting.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests of the warning reporting for different MyST Markdown inputs."""

from io import StringIO
from pathlib import Path

Expand Down
1 change: 1 addition & 0 deletions tests/test_renderers/test_fixtures_docutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

Note, the output AST is before any transforms are applied.
"""

from __future__ import annotations

import shlex
Expand Down
1 change: 1 addition & 0 deletions tests/test_renderers/test_fixtures_sphinx.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

Note, the output AST is before any transforms are applied.
"""

from __future__ import annotations

import json
Expand Down
1 change: 1 addition & 0 deletions tests/test_renderers/test_myst_config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test (docutils) parsing with different ``MdParserConfig`` options set."""

import shlex
from io import StringIO
from pathlib import Path
Expand Down
1 change: 1 addition & 0 deletions tests/test_sphinx/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def test_basic(app, status, warning, get_sphinx_app_output):
- docutilsconf=None

"""

import os
import pathlib
import shutil
Expand Down
1 change: 1 addition & 0 deletions tests/test_sphinx/test_sphinx_builds.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
which uses semantic HTML tags
(e.g. converting `<div class="section">` to `<section>`)
"""

import os
import re

Expand Down
Loading