diff --git a/.github/workflows/continuous-integration-workflow.yml b/.github/workflows/continuous-integration-workflow.yml index 6948013..6b44166 100644 --- a/.github/workflows/continuous-integration-workflow.yml +++ b/.github/workflows/continuous-integration-workflow.yml @@ -18,7 +18,7 @@ jobs: fail-fast: false matrix: os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] - python-version: ['3.6', '3.7', '3.8', '3.9'] + python-version: ['3.7', '3.8', '3.9', '3.10'] steps: - uses: actions/checkout@v2 @@ -50,7 +50,7 @@ jobs: run: tox -e pytest -- src tests -m "unit or (not integration and not end_to_end)" --cov=./ --cov-report=xml -n auto - name: Upload coverage report for unit tests and doctests. - if: runner.os == 'Linux' && matrix.python-version == '3.8' + if: runner.os == 'Linux' && matrix.python-version == '3.9' shell: bash -l {0} run: bash <(curl -s https://codecov.io/bash) -F unit -c @@ -59,6 +59,6 @@ jobs: run: tox -e pytest -- src tests -m end_to_end --cov=./ --cov-report=xml -n auto - name: Upload coverage reports of end-to-end tests. - if: runner.os == 'Linux' && matrix.python-version == '3.8' + if: runner.os == 'Linux' && matrix.python-version == '3.9' shell: bash -l {0} run: bash <(curl -s https://codecov.io/bash) -F end_to_end -c diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 45ed0a9..70438d3 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.0.1 + rev: v4.1.0 hooks: - id: check-added-large-files args: ['--maxkb=25'] @@ -22,24 +22,25 @@ repos: - id: rst-inline-touching-normal - id: text-unicode-replacement-char - repo: https://github.com/asottile/pyupgrade - rev: v2.29.0 + rev: v2.31.0 hooks: - id: pyupgrade - args: [--py36-plus] + args: [--py37-plus] - repo: https://github.com/asottile/reorder_python_imports - rev: v2.6.0 + rev: v2.7.1 hooks: - id: reorder-python-imports + args: [--py37-plus, --add-import, 'from __future__ import annotations'] - repo: https://github.com/asottile/setup-cfg-fmt - rev: v1.19.0 + rev: v1.20.0 hooks: - id: setup-cfg-fmt - repo: https://github.com/psf/black - rev: 21.10b0 + rev: 22.1.0 hooks: - id: black - repo: https://github.com/asottile/blacken-docs - rev: v1.11.0 + rev: v1.12.1 hooks: - id: blacken-docs additional_dependencies: [black] diff --git a/setup.py b/setup.py index 26e08e4..c21a9ee 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from setuptools import setup diff --git a/src/latex_dependency_scanner/__init__.py b/src/latex_dependency_scanner/__init__.py index bbc1946..d2bed4e 100644 --- a/src/latex_dependency_scanner/__init__.py +++ b/src/latex_dependency_scanner/__init__.py @@ -1,4 +1,6 @@ """The name space for the package.""" +from __future__ import annotations + from latex_dependency_scanner.compile import compile_pdf from latex_dependency_scanner.scanner import scan diff --git a/src/latex_dependency_scanner/compile.py b/src/latex_dependency_scanner/compile.py index 87d5090..4de8227 100644 --- a/src/latex_dependency_scanner/compile.py +++ b/src/latex_dependency_scanner/compile.py @@ -4,12 +4,12 @@ be used by users to compile their documents. """ +from __future__ import annotations + import os import shutil import subprocess from pathlib import Path -from typing import List -from typing import Optional DEFAULT_OPTIONS = ["--pdf", "--interaction=nonstopmode", "--synctex=1", "--cd"] @@ -17,8 +17,8 @@ def compile_pdf( latex_document: Path, - compiled_document: Optional[Path] = None, - args: Optional[List[str]] = None, + compiled_document: Path | None = None, + args: list[str] | None = None, ): """Generate a PDF from LaTeX document.""" if shutil.which("latexmk") is None: @@ -30,8 +30,8 @@ def compile_pdf( def _prepare_cmd_options( latex_document: Path, - compiled_document: Optional[Path] = None, - args: Optional[List[str]] = None, + compiled_document: Path | None = None, + args: list[str] | None = None, ): """Prepare the command line arguments to compile the LaTeX document. diff --git a/src/latex_dependency_scanner/scanner.py b/src/latex_dependency_scanner/scanner.py index 2bccea5..cc89d16 100644 --- a/src/latex_dependency_scanner/scanner.py +++ b/src/latex_dependency_scanner/scanner.py @@ -1,10 +1,10 @@ """Includes the ability to scan a LaTeX document.""" +from __future__ import annotations + import re from os.path import splitext from pathlib import Path -from typing import List -from typing import Optional -from typing import Union + COMMON_TEX_EXTENSIONS = [".ltx", ".tex"] """List[str]: List of typical file extensions that contain latex""" @@ -47,7 +47,7 @@ document.""" -def scan(paths: Union[Path, List[Path]]): +def scan(paths: Path | list[Path]): """Scan the documents provided as paths for included files. Parameters @@ -70,8 +70,8 @@ def scan(paths: Union[Path, List[Path]]): def yield_nodes_from_node( node: Path, - nodes: List[Path], - relative_to: Optional[Path] = None, + nodes: list[Path], + relative_to: Path | None = None, ): r"""Yield nodes from node. diff --git a/tests/conftest.py b/tests/conftest.py index 01e8c42..6cc38a2 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,6 @@ """Configuration file for pytest.""" +from __future__ import annotations + import shutil from pathlib import Path diff --git a/tests/test_regex.py b/tests/test_regex.py index e2be846..4ea93e8 100644 --- a/tests/test_regex.py +++ b/tests/test_regex.py @@ -1,4 +1,6 @@ """Test regular expressions.""" +from __future__ import annotations + import pytest from latex_dependency_scanner.scanner import REGEX_TEX diff --git a/tests/test_scan.py b/tests/test_scan.py index 0706f05..4ddfeea 100644 --- a/tests/test_scan.py +++ b/tests/test_scan.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import shutil import textwrap