From a927ef79ab17b94b3bd64839a6a70ae7ae01219c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 22 Apr 2024 19:13:41 +0000 Subject: [PATCH 1/4] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/pre-commit-hooks: v4.4.0 → v4.6.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.4.0...v4.6.0) - [github.com/asottile/reorder-python-imports: v3.11.0 → v3.12.0](https://github.com/asottile/reorder-python-imports/compare/v3.11.0...v3.12.0) - [github.com/asottile/setup-cfg-fmt: v2.4.0 → v2.5.0](https://github.com/asottile/setup-cfg-fmt/compare/v2.4.0...v2.5.0) - [github.com/psf/black: 23.9.1 → 24.4.0](https://github.com/psf/black/compare/23.9.1...24.4.0) - [github.com/astral-sh/ruff-pre-commit: v0.0.291 → v0.4.1](https://github.com/astral-sh/ruff-pre-commit/compare/v0.0.291...v0.4.1) - [github.com/econchick/interrogate: 1.5.0 → 1.7.0](https://github.com/econchick/interrogate/compare/1.5.0...1.7.0) - [github.com/codespell-project/codespell: v2.2.5 → v2.2.6](https://github.com/codespell-project/codespell/compare/v2.2.5...v2.2.6) - [github.com/pre-commit/mirrors-mypy: v1.5.1 → v1.9.0](https://github.com/pre-commit/mirrors-mypy/compare/v1.5.1...v1.9.0) --- .pre-commit-config.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fefc198..8cfdb62 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.6.0 hooks: - id: check-added-large-files args: ['--maxkb=25'] @@ -18,16 +18,16 @@ repos: - id: python-use-type-annotations - id: text-unicode-replacement-char - repo: https://github.com/asottile/reorder-python-imports - rev: v3.11.0 + rev: v3.12.0 hooks: - id: reorder-python-imports args: [--py38-plus, --add-import, 'from __future__ import annotations'] - repo: https://github.com/asottile/setup-cfg-fmt - rev: v2.4.0 + rev: v2.5.0 hooks: - id: setup-cfg-fmt - repo: https://github.com/psf/black - rev: 23.9.1 + rev: 24.4.0 hooks: - id: black - repo: https://github.com/asottile/blacken-docs @@ -36,7 +36,7 @@ repos: - id: blacken-docs additional_dependencies: [black] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.291 + rev: v0.4.1 hooks: - id: ruff - repo: https://github.com/executablebooks/mdformat @@ -50,16 +50,16 @@ repos: args: [--wrap, "88"] files: (README\.md) - repo: https://github.com/econchick/interrogate - rev: 1.5.0 + rev: 1.7.0 hooks: - id: interrogate args: [-v, --fail-under=40, src, tests] - repo: https://github.com/codespell-project/codespell - rev: v2.2.5 + rev: v2.2.6 hooks: - id: codespell - repo: https://github.com/pre-commit/mirrors-mypy - rev: 'v1.5.1' + rev: 'v1.9.0' hooks: - id: mypy args: [ From 82698f0fdf72a1113402c2a4ea2de276b082c4fd Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 22 Apr 2024 19:14:05 +0000 Subject: [PATCH 2/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/latex_dependency_scanner/__init__.py | 1 + src/latex_dependency_scanner/compile.py | 1 + src/latex_dependency_scanner/scanner.py | 9 ++++++--- tests/conftest.py | 1 + tests/test_regex.py | 1 + 5 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/latex_dependency_scanner/__init__.py b/src/latex_dependency_scanner/__init__.py index d2bed4e..51b96f5 100644 --- a/src/latex_dependency_scanner/__init__.py +++ b/src/latex_dependency_scanner/__init__.py @@ -1,4 +1,5 @@ """The name space for the package.""" + from __future__ import annotations from latex_dependency_scanner.compile import compile_pdf diff --git a/src/latex_dependency_scanner/compile.py b/src/latex_dependency_scanner/compile.py index be159ed..11c3b3b 100644 --- a/src/latex_dependency_scanner/compile.py +++ b/src/latex_dependency_scanner/compile.py @@ -4,6 +4,7 @@ be used by users to compile their documents. """ + from __future__ import annotations import os diff --git a/src/latex_dependency_scanner/scanner.py b/src/latex_dependency_scanner/scanner.py index 049d9f1..4c1fa38 100644 --- a/src/latex_dependency_scanner/scanner.py +++ b/src/latex_dependency_scanner/scanner.py @@ -1,4 +1,5 @@ """Includes the ability to scan a LaTeX document.""" + from __future__ import annotations import re @@ -163,9 +164,11 @@ def yield_nodes_from_node( # noqa: C901, PLR0912 if not found_some_file: possible_paths = ( - (relative_to / path).resolve().with_suffix(suffix) - if suffix - else (relative_to / path).resolve() + ( + (relative_to / path).resolve().with_suffix(suffix) + if suffix + else (relative_to / path).resolve() + ) for suffix in common_extensions ) yield from possible_paths diff --git a/tests/conftest.py b/tests/conftest.py index 6cc38a2..2f7f521 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,5 @@ """Configuration file for pytest.""" + from __future__ import annotations import shutil diff --git a/tests/test_regex.py b/tests/test_regex.py index 20cc87d..c037747 100644 --- a/tests/test_regex.py +++ b/tests/test_regex.py @@ -1,4 +1,5 @@ """Test regular expressions.""" + from __future__ import annotations import pytest From 117e8bf8d09579b11129865c8f9a29efddcd975a Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Thu, 25 Apr 2024 00:06:55 +0200 Subject: [PATCH 3/4] FIx. --- .pre-commit-config.yaml | 40 ++-------------------- pyproject.toml | 45 +++++++------------------ src/latex_dependency_scanner/compile.py | 6 ++-- src/latex_dependency_scanner/scanner.py | 1 - tests/conftest.py | 1 - tests/test_scan.py | 2 +- 6 files changed, 19 insertions(+), 76 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8cfdb62..0b13bc5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,28 +17,11 @@ repos: - id: python-no-log-warn - id: python-use-type-annotations - id: text-unicode-replacement-char -- repo: https://github.com/asottile/reorder-python-imports - rev: v3.12.0 - hooks: - - id: reorder-python-imports - args: [--py38-plus, --add-import, 'from __future__ import annotations'] -- repo: https://github.com/asottile/setup-cfg-fmt - rev: v2.5.0 - hooks: - - id: setup-cfg-fmt -- repo: https://github.com/psf/black - rev: 24.4.0 - hooks: - - id: black -- repo: https://github.com/asottile/blacken-docs - rev: 1.16.0 - hooks: - - id: blacken-docs - additional_dependencies: [black] - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.4.1 hooks: - id: ruff + - id: ruff-format - repo: https://github.com/executablebooks/mdformat rev: 0.7.17 hooks: @@ -49,35 +32,16 @@ repos: ] args: [--wrap, "88"] files: (README\.md) -- repo: https://github.com/econchick/interrogate - rev: 1.7.0 - hooks: - - id: interrogate - args: [-v, --fail-under=40, src, tests] - repo: https://github.com/codespell-project/codespell rev: v2.2.6 hooks: - id: codespell -- repo: https://github.com/pre-commit/mirrors-mypy - rev: 'v1.9.0' - hooks: - - id: mypy - args: [ - --no-strict-optional, - --ignore-missing-imports, - ] - additional_dependencies: [ - types-attrs, - types-click, - types-setuptools - ] - pass_filenames: false - repo: https://github.com/mgedmin/check-manifest rev: "0.49" hooks: - id: check-manifest args: [--no-build-isolation] - additional_dependencies: [setuptools-scm, toml] + additional_dependencies: [setuptools-scm, wheel, toml] - repo: meta hooks: - id: check-hooks-apply diff --git a/pyproject.toml b/pyproject.toml index 1f82d62..0738583 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,11 +2,9 @@ requires = ["setuptools>=45", "wheel", "setuptools_scm[toml]>=6.0"] build-backend = "setuptools.build_meta" - [tool.setuptools_scm] write_to = "src/latex_dependency_scanner/_version.py" - [tool.mypy] files = ["src", "tests"] check_untyped_defs = true @@ -17,45 +15,28 @@ no_implicit_optional = true warn_redundant_casts = true warn_unused_ignores = true - [[tool.mypy.overrides]] module = "tests.*" disallow_untyped_defs = false ignore_errors = true - [tool.ruff] target-version = "py38" -select = ["ALL"] fix = true +unsafe-fixes = true + +[tool.ruff.lint] extend-ignore = [ - # Numpy docstyle - "D107", - "D203", - "D212", - "D213", - "D402", - "D404", - "D413", - "D415", - "D416", - "D417", - # Others. - "RET504", # unnecessary variable assignment before return. - "S101", # raise errors for asserts. - "B905", # strict parameter for zip that was implemented in py310. - "I", # ignore isort - "ANN101", # type annotating self - "ANN102", # type annotating cls - "FBT", # flake8-boolean-trap - "EM", # flake8-errmsg - "ANN401", # flake8-annotate typing.Any - "PD", # pandas-vet - "UP", # pyupgrade is too aggressive for py<3.10 - "COM812", # trailing comma missing, but black takes care of that - "TRY003", # avoid long exception messages + "COM812", # Comply with ruff-format + "ISC001", # Comply with ruff-format ] +select = ["ALL"] + +[tool.ruff.lint.per-file-ignores] +"tests/*" = ["ANN", "D", "S101"] +[tool.ruff.lint.isort] +force-single-line = true -[tool.ruff.per-file-ignores] -"tests/*" = ["D", "ANN"] +[tool.ruff.lint.pydocstyle] +convention = "numpy" diff --git a/src/latex_dependency_scanner/compile.py b/src/latex_dependency_scanner/compile.py index 11c3b3b..4dee5d7 100644 --- a/src/latex_dependency_scanner/compile.py +++ b/src/latex_dependency_scanner/compile.py @@ -1,4 +1,4 @@ -"""This module provides the means to compile a LaTeX document to a desired location. +"""Provides the means to compile a LaTeX document to a desired location. The function is mainly used in testing to validate the provided examples, but can also be used by users to compile their documents. @@ -13,7 +13,6 @@ from pathlib import Path from subprocess import CompletedProcess - DEFAULT_OPTIONS = ["--pdf", "--interaction=nonstopmode", "--synctex=1", "--cd"] @@ -24,7 +23,8 @@ def compile_pdf( ) -> CompletedProcess[bytes]: """Generate a PDF from LaTeX document.""" if shutil.which("latexmk") is None: - raise RuntimeError("'latexmk' must be on PATH to compile a LaTeX document.") + msg = "'latexmk' must be on PATH to compile a LaTeX document." + raise RuntimeError(msg) cmd = _prepare_cmd_options(latex_document, compiled_document, args) return subprocess.run(cmd, check=True) # noqa: S603 diff --git a/src/latex_dependency_scanner/scanner.py b/src/latex_dependency_scanner/scanner.py index 4c1fa38..fe6aa29 100644 --- a/src/latex_dependency_scanner/scanner.py +++ b/src/latex_dependency_scanner/scanner.py @@ -6,7 +6,6 @@ from pathlib import Path from typing import Generator - COMMON_TEX_EXTENSIONS = [".ltx", ".tex"] """List[str]: List of typical file extensions that contain latex""" diff --git a/tests/conftest.py b/tests/conftest.py index 2f7f521..dfdd6eb 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -7,7 +7,6 @@ import pytest - needs_latexmk = pytest.mark.skipif( shutil.which("latexmk") is None, reason="latexmk needs to be installed." ) diff --git a/tests/test_scan.py b/tests/test_scan.py index 9e5c129..ecff6d7 100644 --- a/tests/test_scan.py +++ b/tests/test_scan.py @@ -8,8 +8,8 @@ from latex_dependency_scanner.scanner import COMMON_GRAPHICS_EXTENSIONS from latex_dependency_scanner.scanner import scan -from tests.conftest import needs_latexmk from tests.conftest import TEST_RESOURCES +from tests.conftest import needs_latexmk @needs_latexmk From 8521e94275ef7fe0055f144ce4270e68920f92f4 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Thu, 25 Apr 2024 00:08:33 +0200 Subject: [PATCH 4/4] add pyton 3.12. --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1df0f21..17d4e40 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -27,7 +27,7 @@ jobs: fail-fast: false matrix: os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] - python-version: ['3.8', '3.9', '3.10', '3.11'] + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] steps: - uses: actions/checkout@v4