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 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fefc198..0b13bc5 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'] @@ -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.11.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 - hooks: - - id: setup-cfg-fmt -- repo: https://github.com/psf/black - rev: 23.9.1 - 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.0.291 + 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.5.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' - 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/__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..4dee5d7 100644 --- a/src/latex_dependency_scanner/compile.py +++ b/src/latex_dependency_scanner/compile.py @@ -1,9 +1,10 @@ -"""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. """ + from __future__ import annotations import os @@ -12,7 +13,6 @@ from pathlib import Path from subprocess import CompletedProcess - DEFAULT_OPTIONS = ["--pdf", "--interaction=nonstopmode", "--synctex=1", "--cd"] @@ -23,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 049d9f1..fe6aa29 100644 --- a/src/latex_dependency_scanner/scanner.py +++ b/src/latex_dependency_scanner/scanner.py @@ -1,11 +1,11 @@ """Includes the ability to scan a LaTeX document.""" + from __future__ import annotations import re from pathlib import Path from typing import Generator - COMMON_TEX_EXTENSIONS = [".ltx", ".tex"] """List[str]: List of typical file extensions that contain latex""" @@ -163,9 +163,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..dfdd6eb 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,5 @@ """Configuration file for pytest.""" + from __future__ import annotations import shutil @@ -6,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_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 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