From 5ed750f821e7a47e6d1cdb41b208898d9f51e006 Mon Sep 17 00:00:00 2001 From: Phillip Cloud <417981+cpcloud@users.noreply.github.com> Date: Sat, 9 Sep 2023 08:04:13 -0400 Subject: [PATCH] chore(dev-deps): add `blackdoc` for docstring code formatting --- .pre-commit-config.yaml | 5 +++++ docs/_renderer.py | 4 +++- justfile | 1 + poetry.lock | 31 ++++++++++++++++++++++++++++++- pyproject.toml | 4 ++++ requirements-dev.txt | 4 +++- 6 files changed, 46 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8a58c839baa9..b57072eb64ed 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,6 +24,11 @@ repos: rev: 23.9.1 hooks: - id: black + - repo: https://github.com/keewis/blackdoc + rev: v0.3.8 + hooks: + - id: blackdoc + exclude: ibis/examples/__init__\.py - repo: https://github.com/codespell-project/codespell rev: v2.2.5 hooks: diff --git a/docs/_renderer.py b/docs/_renderer.py index 459f752e3313..452ba9ff66d5 100644 --- a/docs/_renderer.py +++ b/docs/_renderer.py @@ -44,7 +44,9 @@ def render(self, el: qd.ast.ExampleCode) -> str: # if we expect failures, don't fail the notebook execution and # render the error message - if expect_failure in first: + if expect_failure in first or any( + expect_failure in line for line in rest + ): assert ( start and end ), "expected failure should never occur alongside a skipped doctest example" diff --git a/justfile b/justfile index 5a7a406c1d21..52ac3f662dca 100644 --- a/justfile +++ b/justfile @@ -25,6 +25,7 @@ lock: # format code fmt: black . + blackdoc . ruff --fix . # run all non-backend tests; additional arguments are forwarded to pytest diff --git a/poetry.lock b/poetry.lock index 56f086954d61..d72f9b90af1b 100644 --- a/poetry.lock +++ b/poetry.lock @@ -437,6 +437,24 @@ d = ["aiohttp (>=3.7.4)"] jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"] uvloop = ["uvloop (>=0.15.2)"] +[[package]] +name = "blackdoc" +version = "0.3.8" +description = "run black on documentation code snippets" +optional = false +python-versions = ">=3.7" +files = [ + {file = "blackdoc-0.3.8-py3-none-any.whl", hash = "sha256:c003a1b72d57692b343815c8b7a15e78977caba96c86060def892602b5aba083"}, + {file = "blackdoc-0.3.8.tar.gz", hash = "sha256:3c9d5534f92557a627a31550c7faec8363b5b0929bbb0ca3f5df179a81a9d6b2"}, +] + +[package.dependencies] +black = "*" +more-itertools = "*" +pathspec = "*" +rich = "*" +tomli = "*" + [[package]] name = "cachetools" version = "5.3.1" @@ -2764,6 +2782,17 @@ doc = ["numpydoc (>=0.9.1)", "sphinx (>=6.1.0)"] lint = ["black (>=23.1.0)", "ruff"] test = ["pytest-cov"] +[[package]] +name = "more-itertools" +version = "10.1.0" +description = "More routines for operating on iterables, beyond itertools" +optional = false +python-versions = ">=3.8" +files = [ + {file = "more-itertools-10.1.0.tar.gz", hash = "sha256:626c369fa0eb37bac0291bce8259b332fd59ac792fa5497b59837309cd5b114a"}, + {file = "more_itertools-10.1.0-py3-none-any.whl", hash = "sha256:64e0735fcfdc6f3464ea133afe8ea4483b1c5fe3a3d69852e6503b43a0b222e6"}, +] + [[package]] name = "multidict" version = "6.0.4" @@ -5907,4 +5936,4 @@ visualization = ["graphviz"] [metadata] lock-version = "2.0" python-versions = "^3.9" -content-hash = "6863640d8684a49a7647f419cbcf4a690ea0354473f0cf68f088976cbeeb1796" +content-hash = "47b7a59be009060e1c6e528c7271624b0e31344e969b69a11be110632d2f8584" diff --git a/pyproject.toml b/pyproject.toml index 739d656f72c3..f3f0725f219c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -98,6 +98,7 @@ trino = { version = ">=0.321,<1", optional = true, extras = ["sqlalchemy"] } [tool.poetry.group.dev.dependencies] black = ">=22.1.0,<24" +blackdoc = ">=0.3.8,<1" codespell = { version = ">=2.2.4,<3", extras = [ "hard-encoding-detection", "toml", @@ -477,6 +478,9 @@ required-imports = ["from __future__ import annotations"] "docs/*.py" = ["INP001"] "ci/release/verify_release.py" = ["T201"] # CLI tool that prints stuff +[tool.blackdoc] +extend_exclude = 'ibis/examples/__init__\.py' + [tool.black] line_length = 88 extend_exclude = '\.direnv|result(-\d+)|_py310\.py|decompiled\.py' diff --git a/requirements-dev.txt b/requirements-dev.txt index d5ee455b2b4b..b67bfe56a3a1 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -13,6 +13,7 @@ beartype==0.15.0 ; python_version >= "3.10" and python_version < "4.0" bidict==0.22.1 ; python_version >= "3.9" and python_version < "4.0" bitarray==2.8.1 ; python_version >= "3.9" and python_version < "4.0" black==23.9.1 ; python_version >= "3.9" and python_version < "4.0" +blackdoc==0.3.8 ; python_version >= "3.9" and python_version < "4.0" cachetools==5.3.1 ; python_version >= "3.9" and python_version < "4.0" certifi==2023.7.22 ; python_version >= "3.9" and python_version < "4.0" cffi==1.15.1 ; python_version >= "3.9" and python_version < "4.0" @@ -95,6 +96,7 @@ matplotlib-inline==0.1.6 ; python_version >= "3.9" and python_version < "4.0" matplotlib==3.7.2 ; python_version >= "3.10" and python_version < "4.0" mdurl==0.1.2 ; python_version >= "3.9" and python_version < "4.0" mizani==0.9.2 ; python_version >= "3.10" and python_version < "4.0" +more-itertools==10.1.0 ; python_version >= "3.9" and python_version < "4.0" multidict==6.0.4 ; python_version >= "3.9" and python_version < "4.0" multipledispatch==1.0.0 ; python_version >= "3.9" and python_version < "4.0" mypy-extensions==1.0.0 ; python_version >= "3.9" and python_version < "4.0" @@ -200,7 +202,7 @@ tenacity==8.2.3 ; python_version >= "3.10" and python_version < "4.0" threadpoolctl==3.2.0 ; python_version >= "3.10" and python_version < "4.0" thrift-sasl==0.4.3 ; python_version >= "3.9" and python_version < "4.0" thrift==0.16.0 ; python_version >= "3.9" and python_version < "4.0" -tomli==2.0.1 ; python_version >= "3.9" and python_full_version <= "3.11.0a6" +tomli==2.0.1 ; python_version >= "3.9" and python_version < "4.0" tomlkit==0.12.1 ; python_version >= "3.9" and python_version < "4.0" toolz==0.12.0 ; python_version >= "3.9" and python_version < "4.0" tornado==6.3.3 ; python_version >= "3.10" and python_version < "4.0"