Skip to content

Commit

Permalink
👷 Update pre-commit.ci
Browse files Browse the repository at this point in the history
  • Loading branch information
Freed-Wu committed Feb 19, 2024
1 parent d16ad1c commit b19de8e
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 67 deletions.
52 changes: 16 additions & 36 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-added-large-files
- id: fix-byte-order-marker
Expand All @@ -26,7 +26,7 @@ repos:
hooks:
- id: remove-crlf
- repo: https://github.com/codespell-project/codespell
rev: v2.2.5
rev: v2.2.6
hooks:
- id: codespell
additional_dependencies:
Expand All @@ -38,23 +38,23 @@ repos:
args:
- --msg-filename
- repo: https://github.com/editorconfig-checker/editorconfig-checker.python
rev: 2.7.2
rev: 2.7.3
hooks:
- id: editorconfig-checker
- repo: https://github.com/jumanjihouse/pre-commit-hooks
rev: 3.0.0
hooks:
- id: check-mailmap
- repo: https://github.com/rhysd/actionlint
rev: v1.6.25
rev: v1.6.26
hooks:
- id: actionlint
- repo: https://github.com/adrienverge/yamllint
rev: v1.32.0
rev: v1.35.1
hooks:
- id: yamllint
- repo: https://github.com/executablebooks/mdformat
rev: 0.7.16
rev: 0.7.17
hooks:
- id: mdformat
additional_dependencies:
Expand All @@ -64,53 +64,33 @@ repos:
- mdformat-toc
- mdformat-deflist
- mdformat-beautysh
- mdformat-black
- mdformat-ruff
- mdformat-config
- mdformat-web
- repo: https://github.com/DavidAnson/markdownlint-cli2
rev: v0.8.1
rev: v0.12.1
hooks:
- id: markdownlint-cli2
additional_dependencies:
- markdown-it-texmath@0.9.1
- markdown-it-texmath
- repo: https://github.com/Freed-Wu/pre-commit-hooks
rev: 0.0.11
hooks:
- id: update-CITATION.cff
- id: update-pyproject.toml
- repo: https://github.com/perltidy/perltidy
rev: "20230701.02"
rev: "20230912.13"
hooks:
- id: perltidy
- repo: https://github.com/psf/black
rev: 23.7.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.1
hooks:
- id: black
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/pycqa/pydocstyle
rev: 6.3.0
hooks:
- id: pydocstyle
additional_dependencies:
- tomli
- id: ruff
- id: ruff-format
- repo: https://github.com/kumaraditya303/mirrors-pyright
rev: v1.1.322
rev: v1.1.350
hooks:
- id: pyright
- repo: https://github.com/PyCQA/bandit
rev: 1.7.5
hooks:
- id: bandit
args:
- -cpyproject.toml
additional_dependencies:
- tomli
- repo: https://github.com/nix-community/nixpkgs-fmt
rev: v1.3.0
hooks:
- id: nixpkgs-fmt

ci:
skip:
Expand Down
3 changes: 1 addition & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
https://www.sphinx-doc.org/en/master/usage/configuration.html
"""

import os
from datetime import datetime

from sphinxcontrib.eval import __version__ as version

try:
import tomllib # type: ignore
except ImportError:
Expand Down
60 changes: 40 additions & 20 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ build-backend = "setuptools.build_meta"
[project]
name = "sphinxcontrib-eval"
description = "Evaluate shell command or python code in sphinx and myst"
authors = [{ name = "Wu Zhenyu", email = "[email protected]" }]
readme = "README.md"
requires-python = ">= 3.9"
keywords = ["sphinx", "myst", "eval"]
license = { text = "GPL v3" }
classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
Expand All @@ -25,9 +23,19 @@ classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
]
dynamic = ["version", "dependencies", "optional-dependencies"]

[[project.authors]]
name = "Wu Zhenyu"
email = "[email protected]"

[project.license]
text = "GPL v3"

[project.urls]
Homepage = "https://sphinxcontrib-eval.readthedocs.io"
Download = "https://github.com/sphinx-contrib/eval/releases"
Expand All @@ -40,8 +48,8 @@ write_to = "src/sphinxcontrib/eval/_version.py"
[tool.setuptools.package-data]
"sphinxcontrib.eval" = ["py.typed"]

[tool.setuptools.dynamic]
dependencies = { file = "requirements.txt" }
[tool.setuptools.dynamic.dependencies]
file = "requirements.txt"

# begin: scripts/update-pyproject.toml.pl
[tool.setuptools.dynamic.optional-dependencies.dev]
Expand All @@ -54,25 +62,37 @@ file = "requirements/myst.txt"
[tool.mdformat]
number = true

[tool.black]
line-length = 79

[tool.isort]
line_length = 79
profile = "black"

# https://github.com/PyCQA/pydocstyle/issues/418
[tool.pydocstyle]
add_ignore = "D205, D400"

[tool.doq]
template_path = "templates"

[tool.bandit]
skips = ["B404"]
[tool.ruff]
line-length = 79

[tool.bandit.assert_used]
skips = ["tests/*.py", "*_test.py", "test_*.py"]
[tool.ruff.lint]
select = [
# pycodestyle
"E",
# pyflakes
"F",
# pyupgrade
"UP",
# flake8-bugbear
"B",
# flake8-simplify
"SIM",
# isort
"I",
]
ignore = ["D205", "D400"]
preview = true

[tool.ruff.format]
docstring-code-format = true
preview = true

[tool.coverage.report]
exclude_lines = ["if TYPE_CHECKING:", "if __name__ == .__main__.:"]
exclude_lines = [
"if TYPE_CHECKING:",
"if __name__ == .__main__.:",
"\\s*import tomli as tomllib",
]
3 changes: 2 additions & 1 deletion src/sphinxcontrib/eval/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Provide ``setup()`` to
`sphinx <https://www.sphinx-doc.org/en/master/extdev/index.html>`_.
"""

from __future__ import annotations

import io
Expand All @@ -12,7 +13,7 @@
if TYPE_CHECKING:
from sphinx.application import Sphinx

from ._version import __version__, __version_tuple__ # type: ignore
from ._version import __version__ # type: ignore
from .rst import RSTEvalParser

SH = os.getenv("SHELL", "sh")
Expand Down
1 change: 1 addition & 0 deletions src/sphinxcontrib/eval/myst.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Provide ``MystEvalParser``.
"""

from myst_parser.parsers.sphinx_ import MystParser

from .utils import patch_parser
Expand Down
1 change: 1 addition & 0 deletions src/sphinxcontrib/eval/rst.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Provide ``RSTEvalParser``.
"""

from sphinx.parsers import RSTParser

from .utils import patch_parser
Expand Down
5 changes: 3 additions & 2 deletions src/sphinxcontrib/eval/utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""Utilities
============
"""

import re
from typing import Callable, Type
from typing import Callable

from docutils.nodes import document
from sphinx.parsers import Parser
Expand Down Expand Up @@ -50,7 +51,7 @@ def replace(
return outputstring


def patch_parser(template: str, parser: Type[Parser]) -> Type[Parser]:
def patch_parser(template: str, parser: type[Parser]) -> type[Parser]:
"""Patch parser.
:param template:
Expand Down
9 changes: 4 additions & 5 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
"""Provide ``AppMixin``."""

import os
import shutil
import tempfile
from contextlib import suppress
from functools import update_wrapper
from pathlib import Path

Expand Down Expand Up @@ -62,11 +64,9 @@ def add_node(self, node):
self.nodes.add(node.__name__)

app = App()
try:
# Sphinx 1 doesn't have this
with suppress(AttributeError):
addnodes.setup(app) # type: ignore
except AttributeError:
# Sphinx 1 doesn't have this
pass

return app.nodes

Expand Down Expand Up @@ -202,7 +202,6 @@ def ignore_warnings(self):
@Lazy
def doctree(self):
"""Doctree."""
getattr(self, "build_app")
self.build_app = True # type: ignore
app = self.app
return app.env.get_doctree("content/doc") # type: ignore
Expand Down
2 changes: 1 addition & 1 deletion tests/__init___test.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""Test ``__init__.py``."""

import sys
from shutil import which
from unittest import TestCase

import pytest

from sphinxcontrib.eval import eval_bash, eval_python, eval_sh

from . import AppMixin
Expand Down
1 change: 1 addition & 0 deletions tests/utils_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test utilities."""

import re

from sphinxcontrib.eval.utils import get_lang_map, replace
Expand Down

0 comments on commit b19de8e

Please sign in to comment.