Skip to content

[pre-commit.ci] pre-commit autoupdate #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
46 changes: 5 additions & 41 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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']
Expand All @@ -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:
Expand All @@ -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
Expand Down
45 changes: 13 additions & 32 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
1 change: 1 addition & 0 deletions src/latex_dependency_scanner/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""The name space for the package."""

from __future__ import annotations

from latex_dependency_scanner.compile import compile_pdf
Expand Down
7 changes: 4 additions & 3 deletions src/latex_dependency_scanner/compile.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -12,7 +13,6 @@
from pathlib import Path
from subprocess import CompletedProcess


DEFAULT_OPTIONS = ["--pdf", "--interaction=nonstopmode", "--synctex=1", "--cd"]


Expand All @@ -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
Expand Down
10 changes: 6 additions & 4 deletions src/latex_dependency_scanner/scanner.py
Original file line number Diff line number Diff line change
@@ -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"""

Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""Configuration file for pytest."""

from __future__ import annotations

import shutil
from pathlib import Path

import pytest


needs_latexmk = pytest.mark.skipif(
shutil.which("latexmk") is None, reason="latexmk needs to be installed."
)
Expand Down
1 change: 1 addition & 0 deletions tests/test_regex.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test regular expressions."""

from __future__ import annotations

import pytest
Expand Down
2 changes: 1 addition & 1 deletion tests/test_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down