diff --git a/.github/workflows/autofix.yml b/.github/workflows/autofix.yml index c1835a39..719e1860 100644 --- a/.github/workflows/autofix.yml +++ b/.github/workflows/autofix.yml @@ -22,7 +22,7 @@ jobs: - run: pip install --no-deps -e . - run: ruff --fix-only . - - run: black . + - run: ruff format . - run: git checkout test/testdata/ pdoc/markdown2/ - run: test/test_snapshot.py diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3e1c2e2b..7c95ade3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,7 +18,7 @@ jobs: lint: uses: mhils/workflows/.github/workflows/python-tox.yml@main with: - cmd: tox -e lint -- -v ${{ matrix.args }} + cmd: tox -e lint test: strategy: diff --git a/pdoc/doc.py b/pdoc/doc.py index 352a0a33..139446a9 100644 --- a/pdoc/doc.py +++ b/pdoc/doc.py @@ -1001,7 +1001,9 @@ def signature(self) -> inspect.Signature: ) ) for p in sig.parameters.values(): - p._annotation = safe_eval_type(p.annotation, globalns, localns, mod, self.fullname) # type: ignore + p._annotation = safe_eval_type( # type: ignore + p.annotation, globalns, localns, mod, self.fullname + ) return sig @cached_property diff --git a/pdoc/extract.py b/pdoc/extract.py index 7d885035..d79e53e2 100644 --- a/pdoc/extract.py +++ b/pdoc/extract.py @@ -204,9 +204,7 @@ def mock_some_common_side_effects(): "os.startfile", new=_noop, create=True ), patch("sys.stdout", new=io.StringIO()), patch( "sys.stderr", new=io.StringIO() - ), patch( - "sys.stdin", new=io.StringIO() - ): + ), patch("sys.stdin", new=io.StringIO()): yield diff --git a/pyproject.toml b/pyproject.toml index 3e2448c7..2644af4f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -44,7 +44,6 @@ pdoc = "pdoc.__main__:cli" dev = [ "tox", "ruff", - "black", "mypy", "types-pygments", "pytest", @@ -90,9 +89,6 @@ markers = [ "slow: marks tests as slow.", ] -[tool.black] -extend-exclude = "test/testdata/demo.py" - [[tool.mypy.overrides]] module = "pytest.*" ignore_missing_imports = true @@ -102,8 +98,9 @@ module = "demopackage2" ignore_missing_imports = true [tool.ruff] -line-length = 140 +extend-exclude = ["test/testdata/demo.py"] select = ["E", "F", "I"] +ignore = ["E501"] [tool.ruff.isort] force-single-line = true diff --git a/requirements-dev.txt b/requirements-dev.txt index 92e1c7f3..4155eecf 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,30 +1,26 @@ # -# This file is autogenerated by pip-compile with Python 3.11 +# This file is autogenerated by pip-compile with Python 3.12 # by the following command: # # pip-compile --all-extras --allow-unsafe --output-file=requirements-dev.txt pyproject.toml # attrs==23.1.0 # via hypothesis -black==23.11.0 - # via pdoc (pyproject.toml) cachetools==5.3.2 # via tox chardet==5.2.0 # via tox -click==8.1.7 - # via black colorama==0.4.6 # via tox coverage[toml]==7.3.2 # via pytest-cov -distlib==0.3.7 +distlib==0.3.8 # via virtualenv filelock==3.13.1 # via # tox # virtualenv -hypothesis==6.91.0 +hypothesis==6.92.0 # via pdoc (pyproject.toml) iniconfig==2.0.0 # via pytest @@ -37,22 +33,16 @@ markupsafe==2.1.3 mypy==1.7.1 # via pdoc (pyproject.toml) mypy-extensions==1.0.0 - # via - # black - # mypy + # via mypy packaging==23.2 # via - # black # pyproject-api # pytest # tox -pathspec==0.11.2 - # via black pdoc-pyo3-sample-library==1.0.11 # via pdoc (pyproject.toml) -platformdirs==4.0.0 +platformdirs==4.1.0 # via - # black # tox # virtualenv pluggy==1.3.0 @@ -72,7 +62,7 @@ pytest-cov==4.1.0 # via pdoc (pyproject.toml) pytest-timeout==2.2.0 # via pdoc (pyproject.toml) -ruff==0.1.6 +ruff==0.1.8 # via pdoc (pyproject.toml) sortedcontainers==2.4.0 # via hypothesis @@ -84,7 +74,7 @@ types-pygments==2.17.0.0 # via pdoc (pyproject.toml) types-setuptools==69.0.0.0 # via types-pygments -typing-extensions==4.8.0 +typing-extensions==4.9.0 # via mypy virtualenv==20.25.0 # via tox diff --git a/test/testdata/demopackage/subpackage/__init__.py b/test/testdata/demopackage/subpackage/__init__.py index fcf0af3d..c43de4ee 100755 --- a/test/testdata/demopackage/subpackage/__init__.py +++ b/test/testdata/demopackage/subpackage/__init__.py @@ -6,6 +6,4 @@ from ..child_b import B -__all__ = [ - "B" -] \ No newline at end of file +__all__ = ["B"] diff --git a/test/testdata/demopackage_dir.html b/test/testdata/demopackage_dir.html index 9f6dcbda..c84f2229 100644 --- a/test/testdata/demopackage_dir.html +++ b/test/testdata/demopackage_dir.html @@ -1078,17 +1078,15 @@
1""" - 2A sub-package. - 3 - 4It imports and re-exposes ..child_b.B, and links to `..C` . - 5""" - 6 - 7from ..child_b import B - 8 - 9__all__ = [ -10 "B" -11] +diff --git a/test/testdata/math_misc.html b/test/testdata/math_misc.html index 44f05e85..874fc03e 100644 --- a/test/testdata/math_misc.html +++ b/test/testdata/math_misc.html @@ -86,83 +86,87 @@1""" +2A sub-package. +3 +4It imports and re-exposes ..child_b.B, and links to `..C` . +5""" +6 +7from ..child_b import B +8 +9__all__ = ["B"]3https://github.com/mitmproxy/pdoc/issues/639 4""" 5 - 6def test_stars(): - 7 r""" - 8 Markdown emphasis tokens (`*`) should not be captured in math mode. - 9 -10 Currently broken: $*xyz*$ -11 -12 Workaround (escaping `*`): $\*xyz\*$ -13 -14 Workaround (extra whitespace): $* xyz *$ -15 -16 """ -17 -18def test_math_newline(): -19 r""" -20 Markdown should not consume double backslashes (math newlines) in math mode. -21 -22 Currently broken: + 6 + 7def test_stars(): + 8 r""" + 9 Markdown emphasis tokens (`*`) should not be captured in math mode. +10 +11 Currently broken: $*xyz*$ +12 +13 Workaround (escaping `*`): $\*xyz\*$ +14 +15 Workaround (extra whitespace): $* xyz *$ +16 +17 """ +18 +19 +20def test_math_newline(): +21 r""" +22 Markdown should not consume double backslashes (math newlines) in math mode. 23 -24 $$ -25 \begin{align\*} -26 f(x) &= x^2\\ -27 &= x \cdot x -28 \end{align\*} -29 $$ -30 -31 Workaround (escaping `\\`): +24 Currently broken: +25 +26 $$ +27 \begin{align\*} +28 f(x) &= x^2\\ +29 &= x \cdot x +30 \end{align\*} +31 $$ 32 -33 $$ -34 \begin{align\*} -35 f(x) &= x^2\\\\ -36 &= x \cdot x -37 \end{align\*} -38 $$ -39 """ -40 -41def test_markdown_newline(): -42 r""" -43 Markdown newlines (`\n\n`) should not emit a paragraph break in math mode. -44 -45 Currently broken: -46 -47 $$ -48 x + y +33 Workaround (escaping `\\`): +34 +35 $$ +36 \begin{align\*} +37 f(x) &= x^2\\\\ +38 &= x \cdot x +39 \end{align\*} +40 $$ +41 """ +42 +43 +44def test_markdown_newline(): +45 r""" +46 Markdown newlines (`\n\n`) should not emit a paragraph break in math mode. +47 +48 Currently broken: 49 -50 = z -51 $$ +50 $$ +51 x + y 52 -53 Workaround (no empty lines in math mode): -54 -55 $$ -56 x + y -57 % comment -58 = z -59 $$ -60 """ -61 -62def test_macros(): -63 r""" -64 Markdown should not capture headings (`#`) in math mode. -65 Currently broken: -66 -67 $$ -68 \newcommand{\define}[2] -69 { -70 #1 \quad \text{#2} -71 } -72 \define{e^{i\pi}+1=0}{Euler's identity} -73 $$ -74 -75 -76 Workaround (no lines with leading `#`): -77 -78 $$ -79 \newcommand{\define}[2]{#1 \quad \text{#2}} -80 \define{e^{i\pi}+1=0}{Euler's identity} -81 $$ -82 """ +53 = z +54 $$ +55 +56 Workaround (no empty lines in math mode): +57 +58 $$ +59 x + y +60 % comment +61 = z +62 $$ +63 """ +64 +65 +66def test_macros(): +67 r""" +68 Markdown should not capture headings (`#`) in math mode. +69 Currently broken: +70 +71 $$ +72 \newcommand{\define}[2] +73 { +74 #1 \quad \text{#2} +75 } +76 \define{e^{i\pi}+1=0}{Euler's identity} +77 $$ +78 +79 +80 Workaround (no lines with leading `#`): +81 +82 $$ +83 \newcommand{\define}[2]{#1 \quad \text{#2}} +84 \define{e^{i\pi}+1=0}{Euler's identity} +85 $$ +86 """
7def test_stars(): - 8 r""" - 9 Markdown emphasis tokens (`*`) should not be captured in math mode. -10 -11 Currently broken: $*xyz*$ -12 -13 Workaround (escaping `*`): $\*xyz\*$ -14 -15 Workaround (extra whitespace): $* xyz *$ -16 -17 """ +@@ -214,28 +218,28 @@8def test_stars(): + 9 r""" +10 Markdown emphasis tokens (`*`) should not be captured in math mode. +11 +12 Currently broken: $*xyz*$ +13 +14 Workaround (escaping `*`): $\*xyz\*$ +15 +16 Workaround (extra whitespace): $* xyz *$ +17 +18 """
19def test_math_newline(): -20 r""" -21 Markdown should not consume double backslashes (math newlines) in math mode. -22 -23 Currently broken: +@@ -273,26 +277,26 @@21def test_math_newline(): +22 r""" +23 Markdown should not consume double backslashes (math newlines) in math mode. 24 -25 $$ -26 \begin{align\*} -27 f(x) &= x^2\\ -28 &= x \cdot x -29 \end{align\*} -30 $$ -31 -32 Workaround (escaping `\\`): +25 Currently broken: +26 +27 $$ +28 \begin{align\*} +29 f(x) &= x^2\\ +30 &= x \cdot x +31 \end{align\*} +32 $$ 33 -34 $$ -35 \begin{align\*} -36 f(x) &= x^2\\\\ -37 &= x \cdot x -38 \end{align\*} -39 $$ -40 """ +34 Workaround (escaping `\\`): +35 +36 $$ +37 \begin{align\*} +38 f(x) &= x^2\\\\ +39 &= x \cdot x +40 \end{align\*} +41 $$ +42 """
42def test_markdown_newline(): -43 r""" -44 Markdown newlines (`\n\n`) should not emit a paragraph break in math mode. -45 -46 Currently broken: -47 -48 $$ -49 x + y +@@ -328,27 +332,27 @@45def test_markdown_newline(): +46 r""" +47 Markdown newlines (`\n\n`) should not emit a paragraph break in math mode. +48 +49 Currently broken: 50 -51 = z -52 $$ +51 $$ +52 x + y 53 -54 Workaround (no empty lines in math mode): -55 -56 $$ -57 x + y -58 % comment -59 = z -60 $$ -61 """ +54 = z +55 $$ +56 +57 Workaround (no empty lines in math mode): +58 +59 $$ +60 x + y +61 % comment +62 = z +63 $$ +64 """
63def test_macros(): -64 r""" -65 Markdown should not capture headings (`#`) in math mode. -66 Currently broken: -67 -68 $$ -69 \newcommand{\define}[2] -70 { -71 #1 \quad \text{#2} -72 } -73 \define{e^{i\pi}+1=0}{Euler's identity} -74 $$ -75 -76 -77 Workaround (no lines with leading `#`): -78 -79 $$ -80 \newcommand{\define}[2]{#1 \quad \text{#2}} -81 \define{e^{i\pi}+1=0}{Euler's identity} -82 $$ -83 """ +diff --git a/test/testdata/math_misc.py b/test/testdata/math_misc.py index 55f7dc5a..ba29caba 100644 --- a/test/testdata/math_misc.py +++ b/test/testdata/math_misc.py @@ -3,6 +3,7 @@ https://github.com/mitmproxy/pdoc/issues/639 """ + def test_stars(): r""" Markdown emphasis tokens (`*`) should not be captured in math mode. @@ -15,6 +16,7 @@ def test_stars(): """ + def test_math_newline(): r""" Markdown should not consume double backslashes (math newlines) in math mode. @@ -38,10 +40,11 @@ def test_math_newline(): $$ """ + def test_markdown_newline(): r""" Markdown newlines (`\n\n`) should not emit a paragraph break in math mode. - + Currently broken: $$ @@ -59,6 +62,7 @@ def test_markdown_newline(): $$ """ + def test_macros(): r""" Markdown should not capture headings (`#`) in math mode.67def test_macros(): +68 r""" +69 Markdown should not capture headings (`#`) in math mode. +70 Currently broken: +71 +72 $$ +73 \newcommand{\define}[2] +74 { +75 #1 \quad \text{#2} +76 } +77 \define{e^{i\pi}+1=0}{Euler's identity} +78 $$ +79 +80 +81 Workaround (no lines with leading `#`): +82 +83 $$ +84 \newcommand{\define}[2]{#1 \quad \text{#2}} +85 \define{e^{i\pi}+1=0}{Euler's identity} +86 $$ +87 """