From ecca45cf27d7ff27a1b1145b19de1acd4e04e4ad Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Tue, 16 Apr 2024 18:12:06 +0100 Subject: [PATCH 1/5] Update pre-commit tool versions --- .pre-commit-config.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 19a74b4..a436890 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,29 +1,29 @@ repos: - repo: https://github.com/asottile/pyupgrade - rev: v3.15.0 + rev: v3.15.2 hooks: - id: pyupgrade args: [--py39-plus] - repo: https://github.com/psf/black-pre-commit-mirror - rev: 23.10.1 + rev: 24.4.0 hooks: - id: black - repo: https://github.com/PyCQA/isort - rev: 5.12.0 + rev: 5.13.2 hooks: - id: isort files: \.py$ args: ["--profile", "black"] - repo: https://github.com/PyCQA/flake8 - rev: 6.1.0 + rev: 7.0.0 hooks: - id: flake8 - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v4.6.0 hooks: - id: check-builtin-literals - id: check-added-large-files @@ -45,4 +45,4 @@ repos: rev: 1.16.0 hooks: - id: blacken-docs - additional_dependencies: [black==23.10.1] + additional_dependencies: [black==24.4.0] From 9232794c8600a32bb04e1ffbff2486463fa0c7de Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Tue, 16 Apr 2024 18:13:03 +0100 Subject: [PATCH 2/5] Remove unused coverage settings --- noxfile.py | 3 +-- pyproject.toml | 20 +------------------- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/noxfile.py b/noxfile.py index b460f8a..2173332 100644 --- a/noxfile.py +++ b/noxfile.py @@ -12,8 +12,7 @@ def lint(session): @nox.session(python=["3.9", "3.10", "3.11", "3.12"]) def test(session): session.install("-e", ".[test]", silent=True) - args = session.posargs or ("--cov-report", "term", "--cov", "sphinx_autobuild") - session.run("pytest", *args) + session.run("pytest", *session.posargs) @nox.session(reuse_venv=True) diff --git a/pyproject.toml b/pyproject.toml index 569e4b9..68c2345 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,8 +54,7 @@ dynamic = ["version"] [project.optional-dependencies] docs = [] test = [ - "pytest>=6.0", - "pytest-cov", + "pytest>=6", ] [[project.authors]] @@ -77,20 +76,3 @@ include = [ "tests/", "noxfile.py", ] - -[tool.coverage.run] -branch = true -omit = [ - "*/conftest.py", - "docs/*", -] - -[tool.coverage.report] -exclude_lines = [ - "pragma: no cover", - "NOCOV", - "if __name__ == .__main__.:" -] - -[tool.coverage.html] -directory = ".htmlcov" From 781815ae2be6e34b46798ead94130141602f464b Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Tue, 16 Apr 2024 18:16:03 +0100 Subject: [PATCH 3/5] Sort dependencies --- pyproject.toml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 68c2345..eb43da8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,12 +42,12 @@ classifiers = [ "Topic :: Utilities", ] dependencies = [ - "sphinx", - "starlette>=0.35", - "uvicorn>=0.25", - "websockets>=11.0", - "colorama", - "watchfiles", + "colorama", + "sphinx", + "starlette>=0.35", + "uvicorn>=0.25", + "watchfiles>=0.20", + "websockets>=11", ] dynamic = ["version"] From 48a778cdb193048f19d29cacc76a71ee4a64254b Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Tue, 16 Apr 2024 18:51:02 +0100 Subject: [PATCH 4/5] Adopt Ruff --- .flake8 | 3 -- .pre-commit-config.yaml | 37 ++------------- .ruff.toml | 84 ++++++++++++++++++++++++++++++++++ sphinx_autobuild/__main__.py | 1 - sphinx_autobuild/build.py | 1 - sphinx_autobuild/filter.py | 2 +- sphinx_autobuild/middleware.py | 6 ++- sphinx_autobuild/server.py | 5 +- 8 files changed, 97 insertions(+), 42 deletions(-) delete mode 100644 .flake8 create mode 100644 .ruff.toml diff --git a/.flake8 b/.flake8 deleted file mode 100644 index e4e5eb3..0000000 --- a/.flake8 +++ /dev/null @@ -1,3 +0,0 @@ -[flake8] -max-line-length = 88 -extend-ignore = E203, W503 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a436890..c941efb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,26 +1,9 @@ repos: - - repo: https://github.com/asottile/pyupgrade - rev: v3.15.2 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.3.7 hooks: - - id: pyupgrade - args: [--py39-plus] - - - repo: https://github.com/psf/black-pre-commit-mirror - rev: 24.4.0 - hooks: - - id: black - - - repo: https://github.com/PyCQA/isort - rev: 5.13.2 - hooks: - - id: isort - files: \.py$ - args: ["--profile", "black"] - - - repo: https://github.com/PyCQA/flake8 - rev: 7.0.0 - hooks: - - id: flake8 + - id: ruff + - id: ruff-format - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.6.0 @@ -34,15 +17,3 @@ repos: - id: end-of-file-fixer - id: forbid-new-submodules - id: trailing-whitespace - - - repo: https://github.com/PyCQA/pydocstyle - rev: 6.3.0 - hooks: - - id: pydocstyle - files: src/.*\.py$ - - - repo: https://github.com/asottile/blacken-docs - rev: 1.16.0 - hooks: - - id: blacken-docs - additional_dependencies: [black==24.4.0] diff --git a/.ruff.toml b/.ruff.toml new file mode 100644 index 0000000..e60e99e --- /dev/null +++ b/.ruff.toml @@ -0,0 +1,84 @@ +target-version = "py39" # Pin Ruff to Python 3.9 +line-length = 88 +output-format = "full" +extend-exclude = [ + "noxfile.py", +] + +[lint] +preview = true +ignore = [ + "D100", + "D101", + "D102", + "D103", + "D105", + "D107", + "E203", +# "W503", # unimplemented in Ruff (as of 2024-04-16) +] +select = [ + # flake8-builtins ('A') + "A", + # flake8-unused-arguments ('ARG') + "ARG", + # flake8-async ('ASYNC') + "ASYNC", + # flake8-bugbear ('B') + "B", + # flake8-comprehensions ('C4') + "C4", + # mccabe ('C90') + "C901", + # pydocstyle ('D') + "D", + # pycodestyle ('E') + "E", + # pyflakes ('F') + "F", + # isort ('I') + "I", + # pep8-naming ('N') + "N", + # perflint ('PERF') + "PERF", + # pygrep-hooks ('PGH') + "PGH", + # flake8-pytest-style ('PT') + "PT", + # flake8-quotes ('Q') + "Q", + # flake8-return ('RET') + "RET", + # flake8-raise ('RSE') + "RSE", + # flake8-simplify ('SIM') + "SIM", + # pyupgrade ('UP') + "UP", + # pycodestyle ('W') + "W", +] + +[lint.pydocstyle] +convention = "pep257" + +[lint.per-file-ignores] +"tests/*" = [ + "E501", + "S101", # whitelist ``assert`` for tests + "T201", # whitelist ``print`` for tests +] + +[lint.flake8-quotes] +inline-quotes = "double" + +[lint.isort] +forced-separate = [ + "tests", +] + +[format] +preview = true +quote-style = "double" +docstring-code-format = true diff --git a/sphinx_autobuild/__main__.py b/sphinx_autobuild/__main__.py index d8767d7..a78b6b9 100644 --- a/sphinx_autobuild/__main__.py +++ b/sphinx_autobuild/__main__.py @@ -123,7 +123,6 @@ def _get_sphinx_build_parser(): def _get_parser(): """Get the application's argument parser.""" - parser = argparse.ArgumentParser(allow_abbrev=False) parser.add_argument( "--version", action="version", version=f"sphinx-autobuild {__version__}" diff --git a/sphinx_autobuild/build.py b/sphinx_autobuild/build.py index e918a76..0859dc3 100644 --- a/sphinx_autobuild/build.py +++ b/sphinx_autobuild/build.py @@ -16,7 +16,6 @@ def __init__(self, sphinx_args, *, url_host, pre_build_commands): def __call__(self, *, rebuild: bool = True): """Generate the documentation using ``sphinx``.""" - if rebuild: show(context="Detected change. Rebuilding...") diff --git a/sphinx_autobuild/filter.py b/sphinx_autobuild/filter.py index 8abbfdd..456786f 100644 --- a/sphinx_autobuild/filter.py +++ b/sphinx_autobuild/filter.py @@ -27,7 +27,7 @@ def __call__(self, path): return True # Any regular expression matches. - for regex in self.regex_based_patterns: + for regex in self.regex_based_patterns: # NoQA: SIM110 if regex.search(path): return True diff --git a/sphinx_autobuild/middleware.py b/sphinx_autobuild/middleware.py index d39587a..2652a0c 100644 --- a/sphinx_autobuild/middleware.py +++ b/sphinx_autobuild/middleware.py @@ -1,7 +1,11 @@ from __future__ import annotations +from typing import TYPE_CHECKING + from starlette.datastructures import MutableHeaders -from starlette.types import ASGIApp, Message, Receive, Scope, Send + +if TYPE_CHECKING: + from starlette.types import ASGIApp, Message, Receive, Scope, Send def web_socket_script(ws_url: str) -> str: diff --git a/sphinx_autobuild/server.py b/sphinx_autobuild/server.py index def7737..5f0233c 100644 --- a/sphinx_autobuild/server.py +++ b/sphinx_autobuild/server.py @@ -4,15 +4,16 @@ import os from concurrent.futures import ProcessPoolExecutor from contextlib import AbstractAsyncContextManager, asynccontextmanager +from typing import TYPE_CHECKING import watchfiles -from starlette.types import Receive, Scope, Send from starlette.websockets import WebSocket -TYPE_CHECKING = False if TYPE_CHECKING: from collections.abc import Callable + from starlette.types import Receive, Scope, Send + from sphinx_autobuild.filter import IgnoreFilter From 1d432fed745773608a5fed44278a02aaf68d3fd3 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Tue, 16 Apr 2024 19:02:10 +0100 Subject: [PATCH 5/5] Release 2024.04.16 --- NEWS.rst | 6 ++++++ sphinx_autobuild/__init__.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/NEWS.rst b/NEWS.rst index dc0205d..06cc4a8 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -4,6 +4,12 @@ Changelog unreleased ---------- +2024.04.16 - 2024-04-16 +----------------------- + +* Add a missing dependency on ``watchfiles``. +* Adopt Ruff in place of flake8 and black. + 2024.04.13 - 2024-04-13 ----------------------- diff --git a/sphinx_autobuild/__init__.py b/sphinx_autobuild/__init__.py index 7b3ce75..343ac3a 100644 --- a/sphinx_autobuild/__init__.py +++ b/sphinx_autobuild/__init__.py @@ -1,3 +1,3 @@ """Rebuild Sphinx documentation on changes, with hot reloading in the browser.""" -__version__ = "2024.04.13" +__version__ = "2024.04.16"