From 6a0611ecf16e6316cf3cd3cc98b06272b304190e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Tue, 7 Jan 2025 16:42:20 +0100 Subject: [PATCH] Prospector fix --- .pre-commit-config.yaml | 2 +- .prospector.yaml | 32 ++++------------------------ poetry.lock | 44 ++++++++++++++++++++++++++++++++++++++- pyproject.toml | 19 +++++++++-------- sphinx_prompt/__init__.py | 5 ++--- 5 files changed, 60 insertions(+), 42 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2615a3c..8b535dc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -69,7 +69,7 @@ repos: - --output-format=pylint additional_dependencies: - prospector-profile-duplicated==1.8.0 # pypi - - prospector-profile-utils==1.14.1 # pypi + - prospector-profile-utils==1.15.1 # pypi - ruff==0.7.3 # pypi - repo: https://github.com/renovatebot/pre-commit-hooks rev: 39.42.4 diff --git a/.prospector.yaml b/.prospector.yaml index f2f5656..c5459bd 100644 --- a/.prospector.yaml +++ b/.prospector.yaml @@ -1,38 +1,14 @@ inherits: + - utils:base + - utils:no-design-checks + - utils:fix + - utils:unsafe - duplicated -strictness: veryhigh -max-line-length: 110 -doc-warnings: true - -pycodestyle: - disable: - - E501 # line too long -pydocstyle: - disable: - - D104 # Missing docstring in public package - - D203 # 1 blank line required before class docstring (found 0) - -pylint: - disable: - - line-too-long - - no-else-break - - no-else-return - - too-many-branches - - too-many-statements - - too-many-locals - - missing-module-docstring - - invalid-name mypy: - run: true - options: python-version: '3.10' -pyroma: - run: true -mccabe: - run: false ruff: options: target-version: py310 diff --git a/poetry.lock b/poetry.lock index c16d30e..98bec5f 100644 --- a/poetry.lock +++ b/poetry.lock @@ -703,6 +703,7 @@ pylint-flask = "0.6" pyroma = {version = ">=2.4", optional = true, markers = "extra == \"with-pyroma\" or extra == \"with_everything\""} PyYAML = "*" requirements-detector = ">=1.3.2" +ruff = {version = "*", optional = true, markers = "extra == \"with-ruff\" or extra == \"with_everything\""} setoptconf-tmp = ">=0.3.1,<0.4.0" toml = ">=0.10.2,<0.11.0" @@ -726,6 +727,20 @@ files = [ {file = "prospector_profile_duplicated-1.8.0.tar.gz", hash = "sha256:1565109b016fac05c61dbce38b952bfce3ff054d0c5493d1acad1fc8e9909704"}, ] +[[package]] +name = "prospector-profile-utils" +version = "1.15.1" +description = "Some utility Prospector profiles." +optional = false +python-versions = "<4.0,>=3.9" +files = [ + {file = "prospector_profile_utils-1.15.1-py3-none-any.whl", hash = "sha256:f2585466bb472c49133cfcb17c8a17c70e3aab7b8d594fa3e716c761d37b1b2c"}, + {file = "prospector_profile_utils-1.15.1.tar.gz", hash = "sha256:1070e30518efbcf00d01d24898f798729fa62d04d8e5e2c3db1016826438e01e"}, +] + +[package.dependencies] +prospector = ">=1.13.0" + [[package]] name = "pycodestyle" version = "2.12.1" @@ -1043,6 +1058,33 @@ typing-extensions = {version = ">=4.0.0,<5.0", markers = "python_version < \"3.1 [package.extras] jupyter = ["ipywidgets (>=7.5.1,<9)"] +[[package]] +name = "ruff" +version = "0.8.6" +description = "An extremely fast Python linter and code formatter, written in Rust." +optional = false +python-versions = ">=3.7" +files = [ + {file = "ruff-0.8.6-py3-none-linux_armv6l.whl", hash = "sha256:defed167955d42c68b407e8f2e6f56ba52520e790aba4ca707a9c88619e580e3"}, + {file = "ruff-0.8.6-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:54799ca3d67ae5e0b7a7ac234baa657a9c1784b48ec954a094da7c206e0365b1"}, + {file = "ruff-0.8.6-py3-none-macosx_11_0_arm64.whl", hash = "sha256:e88b8f6d901477c41559ba540beeb5a671e14cd29ebd5683903572f4b40a9807"}, + {file = "ruff-0.8.6-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0509e8da430228236a18a677fcdb0c1f102dd26d5520f71f79b094963322ed25"}, + {file = "ruff-0.8.6-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:91a7ddb221779871cf226100e677b5ea38c2d54e9e2c8ed847450ebbdf99b32d"}, + {file = "ruff-0.8.6-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:248b1fb3f739d01d528cc50b35ee9c4812aa58cc5935998e776bf8ed5b251e75"}, + {file = "ruff-0.8.6-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:bc3c083c50390cf69e7e1b5a5a7303898966be973664ec0c4a4acea82c1d4315"}, + {file = "ruff-0.8.6-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:52d587092ab8df308635762386f45f4638badb0866355b2b86760f6d3c076188"}, + {file = "ruff-0.8.6-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:61323159cf21bc3897674e5adb27cd9e7700bab6b84de40d7be28c3d46dc67cf"}, + {file = "ruff-0.8.6-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7ae4478b1471fc0c44ed52a6fb787e641a2ac58b1c1f91763bafbc2faddc5117"}, + {file = "ruff-0.8.6-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:0c000a471d519b3e6cfc9c6680025d923b4ca140ce3e4612d1a2ef58e11f11fe"}, + {file = "ruff-0.8.6-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:9257aa841e9e8d9b727423086f0fa9a86b6b420fbf4bf9e1465d1250ce8e4d8d"}, + {file = "ruff-0.8.6-py3-none-musllinux_1_2_i686.whl", hash = "sha256:45a56f61b24682f6f6709636949ae8cc82ae229d8d773b4c76c09ec83964a95a"}, + {file = "ruff-0.8.6-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:496dd38a53aa173481a7d8866bcd6451bd934d06976a2505028a50583e001b76"}, + {file = "ruff-0.8.6-py3-none-win32.whl", hash = "sha256:e169ea1b9eae61c99b257dc83b9ee6c76f89042752cb2d83486a7d6e48e8f764"}, + {file = "ruff-0.8.6-py3-none-win_amd64.whl", hash = "sha256:f1d70bef3d16fdc897ee290d7d20da3cbe4e26349f62e8a0274e7a3f4ce7a905"}, + {file = "ruff-0.8.6-py3-none-win_arm64.whl", hash = "sha256:7d7fc2377a04b6e04ffe588caad613d0c460eb2ecba4c0ccbbfe2bc973cbc162"}, + {file = "ruff-0.8.6.tar.gz", hash = "sha256:dcad24b81b62650b0eb8814f576fc65cfee8674772a6e24c9b747911801eeaa5"}, +] + [[package]] name = "semver" version = "3.0.2" @@ -1388,4 +1430,4 @@ type = ["pytest-mypy"] [metadata] lock-version = "2.0" python-versions = ">=3.10,<4.0" -content-hash = "b3d774779d143afeb5bd484d3082c5a7ec242ac52e9872d50813443871380116" +content-hash = "a859ed8789fb4ff0181f6b8326a68b3f63d92904ad02a9c5d41222310fcea588" diff --git a/pyproject.toml b/pyproject.toml index 1043174..ee85d0e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,10 @@ +[tool.ruff] +target-version = "py310" +line-length = 110 + +[tool.ruff.lint.pydocstyle] +convention = "numpy" + [tool.poetry] name = "sphinx-prompt" version = "0.0.0" @@ -45,18 +52,12 @@ certifi = "2024.8.30" jinja2 = "3.1.5" [tool.poetry.group.dev.dependencies] -prospector = { version = "1.13.3", extras = ["with_bandit", "with_mypy", "with_pyroma"] } +prospector = { version = "1.13.3", extras = ["with_bandit", "with_mypy", "with_pyroma", "with_ruff"] } +prospector-profile-utils = "1.15.1" +prospector-profile-duplicated = "1.8.0" pytest = "8.3.4" types-docutils = "0.21.0.20241128" -prospector-profile-duplicated = "1.8.0" - - -[tool.ruff] -target-version = "py310" -line-length = 110 -[tool.ruff.lint.pydocstyle] -convention = "numpy" [build-system] requires = ["poetry-core>=1.0.0", "poetry-plugin-tweak-dependencies-version", "poetry-dynamic-versioning", "poetry-plugin-drop-python-upper-constraint"] build-backend = "poetry.core.masonry.api" diff --git a/sphinx_prompt/__init__.py b/sphinx_prompt/__init__.py index 4af26f3..6e049d4 100644 --- a/sphinx_prompt/__init__.py +++ b/sphinx_prompt/__init__.py @@ -88,8 +88,7 @@ def run(self) -> list[nodes.raw]: location=(self.state.document.settings.env.docname, self.lineno), ) break - else: - self.options[option_name] = self.arguments[idx] + self.options[option_name] = self.arguments[idx] language: str = self.options.get("language") or "text" prompt: str = self.options.get("prompts") or PROMPTS.get(language, "") @@ -142,7 +141,7 @@ def run(self) -> list[nodes.raw]: highlighted_line = highlight("\n".join(statement), Lexer(), HtmlFormatter(nowrap=True)).strip( "\r\n" ) - if len(line) == 0 or not line[-1] == "\\": + if len(line) == 0 or line[-1] != "\\": html += f'{highlighted_line}\n' if prompt is not None: statements = "\n".join(statement)