Skip to content

Commit be50c5a

Browse files
Modernize the package. (#27)
1 parent 28289bb commit be50c5a

File tree

9 files changed

+46
-45
lines changed

9 files changed

+46
-45
lines changed

.github/workflows/main.yml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,24 @@ jobs:
2727
fail-fast: false
2828
matrix:
2929
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
30-
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
30+
python-version: ['3.8', '3.9', '3.10', '3.11']
3131

3232
steps:
3333
- uses: actions/checkout@v4
3434
- uses: r-lib/actions/setup-tinytex@v2
3535
if: runner.os != 'Windows'
36-
- uses: conda-incubator/setup-miniconda@v2
36+
- uses: mamba-org/setup-micromamba@v1
3737
with:
38-
auto-update-conda: true
39-
python-version: ${{ matrix.python-version }}
40-
channels: conda-forge,nodefaults
41-
miniforge-variant: Mambaforge
38+
environment-name: gha-testing
39+
condarc: |
40+
channels:
41+
- nodefaults
42+
- conda-forge
43+
create-args: >-
44+
python=${{ matrix.python-version }}
45+
mamba
46+
tox-conda
47+
cache-environment: true
4248

4349
- name: Install MacOS dependencies.
4450
if: runner.os == 'macOS'
@@ -61,7 +67,7 @@ jobs:
6167
run: tox -e pytest -- src tests -m "unit or (not integration and not end_to_end)" --cov=./ --cov-report=xml -n auto
6268

6369
- name: Upload coverage report for unit tests and doctests.
64-
if: runner.os == 'Linux' && matrix.python-version == '3.9'
70+
if: runner.os == 'Linux' && matrix.python-version == '3.10'
6571
shell: bash -l {0}
6672
run: bash <(curl -s https://codecov.io/bash) -F unit -c
6773

@@ -70,6 +76,6 @@ jobs:
7076
run: tox -e pytest -- src tests -m end_to_end --cov=./ --cov-report=xml -n auto
7177

7278
- name: Upload coverage reports of end-to-end tests.
73-
if: runner.os == 'Linux' && matrix.python-version == '3.9'
79+
if: runner.os == 'Linux' && matrix.python-version == '3.10'
7480
shell: bash -l {0}
7581
run: bash <(curl -s https://codecov.io/bash) -F end_to_end -c

.pre-commit-config.yaml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,30 @@ repos:
1717
- id: python-no-log-warn
1818
- id: python-use-type-annotations
1919
- id: text-unicode-replacement-char
20-
- repo: https://github.com/asottile/reorder_python_imports
21-
rev: v3.9.0
20+
- repo: https://github.com/asottile/reorder-python-imports
21+
rev: v3.11.0
2222
hooks:
2323
- id: reorder-python-imports
24-
args: [--py37-plus, --add-import, 'from __future__ import annotations']
24+
args: [--py38-plus, --add-import, 'from __future__ import annotations']
2525
- repo: https://github.com/asottile/setup-cfg-fmt
26-
rev: v2.2.0
26+
rev: v2.4.0
2727
hooks:
2828
- id: setup-cfg-fmt
2929
- repo: https://github.com/psf/black
30-
rev: 23.1.0
30+
rev: 23.9.1
3131
hooks:
3232
- id: black
3333
- repo: https://github.com/asottile/blacken-docs
34-
rev: 1.13.0
34+
rev: 1.16.0
3535
hooks:
3636
- id: blacken-docs
3737
additional_dependencies: [black]
38-
- repo: https://github.com/charliermarsh/ruff-pre-commit
39-
rev: v0.0.241
38+
- repo: https://github.com/astral-sh/ruff-pre-commit
39+
rev: v0.0.291
4040
hooks:
4141
- id: ruff
4242
- repo: https://github.com/executablebooks/mdformat
43-
rev: 0.7.16
43+
rev: 0.7.17
4444
hooks:
4545
- id: mdformat
4646
additional_dependencies: [
@@ -55,11 +55,11 @@ repos:
5555
- id: interrogate
5656
args: [-v, --fail-under=40, src, tests]
5757
- repo: https://github.com/codespell-project/codespell
58-
rev: v2.2.2
58+
rev: v2.2.5
5959
hooks:
6060
- id: codespell
6161
- repo: https://github.com/pre-commit/mirrors-mypy
62-
rev: 'v0.991'
62+
rev: 'v1.5.1'
6363
hooks:
6464
- id: mypy
6565
args: [

CHANGES.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
This is a record of all past latex-dependency-scanner releases and what went into them
44
in reverse chronological order. Releases follow [semantic versioning](https://semver.org/) and all releases are available on [PyPI](https://pypi.org/project/latex-dependency-scanner) and [Anaconda.org](https://anaconda.org/pytask/latex-dependency-scanner).
55

6-
## 0.1.2 - 2022-xx-xx
6+
## 0.1.2 - 2023-10-02
77

88
- {pull}`21` updates the readme and other infrastructure files.
9+
- {pull}`27` modernizes the package and deprecates Python 3.7.
910

1011
## 0.1.1 - 2022-02-08
1112

environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ channels:
55
- nodefaults
66

77
dependencies:
8-
- python >=3.7
8+
- python >=3.8
99
- pip
1010
- setuptools-scm
1111
- toml

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ ignore_errors = true
2525

2626

2727
[tool.ruff]
28+
target-version = "py38"
2829
select = ["ALL"]
2930
fix = true
3031
extend-ignore = [

setup.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ url = https://github.com/pytask-dev/latex-dependency-scanner
77
author = Tobias Raabe
88
author_email = [email protected]
99
license = MIT
10-
license_file = LICENSE
10+
license_files = LICENSE
1111
platforms = any
1212
classifiers =
1313
Development Status :: 3 - Alpha
@@ -23,7 +23,7 @@ project_urls =
2323

2424
[options]
2525
packages = find:
26-
python_requires = >=3.7
26+
python_requires = >=3.8
2727
package_dir = =src
2828
zip_safe = False
2929

src/latex_dependency_scanner/compile.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def compile_pdf(
2626
raise RuntimeError("'latexmk' must be on PATH to compile a LaTeX document.")
2727

2828
cmd = _prepare_cmd_options(latex_document, compiled_document, args)
29-
return subprocess.run(cmd, check=True)
29+
return subprocess.run(cmd, check=True) # noqa: S603
3030

3131

3232
def _prepare_cmd_options(
@@ -67,7 +67,10 @@ def _prepare_cmd_options(
6767
os.path.relpath(compiled_document.parent, latex_document.parent)
6868
).as_posix()
6969

70-
return ["latexmk", *args, *jobname] + [
70+
return [
71+
"latexmk",
72+
*args,
73+
*jobname,
7174
f"--output-directory={out_relative_to_latex_source}",
7275
latex_document.as_posix(),
7376
]

src/latex_dependency_scanner/scanner.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,12 @@ def scan(paths: Path | list[Path]) -> list[Path]:
6060

6161
nodes: list[Path] = []
6262
for node in paths:
63-
for node_ in yield_nodes_from_node(node, nodes):
64-
nodes.append(node_)
63+
nodes.extend(yield_nodes_from_node(node, nodes))
6564

6665
return nodes
6766

6867

69-
def yield_nodes_from_node( # noqa: C901
68+
def yield_nodes_from_node( # noqa: C901, PLR0912
7069
node: Path,
7170
nodes: list[Path],
7271
relative_to: Path | None = None,
@@ -110,9 +109,13 @@ def yield_nodes_from_node( # noqa: C901
110109
for path in match.group("file").split(","):
111110
if path:
112111
if match.group("type") == "import":
113-
path = relative_to.joinpath(match.group("relative_to"), path)
112+
path = relative_to.joinpath( # noqa: PLW2901
113+
match.group("relative_to"), path
114+
)
114115
elif match.group("type") == "subimport":
115-
path = node.parent.joinpath(match.group("relative_to"), path)
116+
path = node.parent.joinpath( # noqa: PLW2901
117+
match.group("relative_to"), path
118+
)
116119
relative_to = path.parent
117120
else:
118121
pass
@@ -152,9 +155,8 @@ def yield_nodes_from_node( # noqa: C901
152155
yield from yield_nodes_from_node(
153156
path_w_ext, nodes, relative_to
154157
)
155-
else:
156-
if path_w_ext not in nodes:
157-
yield path_w_ext
158+
elif path_w_ext not in nodes:
159+
yield path_w_ext
158160

159161
# Stop loop, if a file has been found.
160162
break

tox.ini

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,6 @@ conda_deps =
1515
commands =
1616
pytest {posargs}
1717

18-
[flake8]
19-
docstring-convention = numpy
20-
ignore =
21-
D ; ignore missing docstrings.
22-
E203 ; ignore whitespace around : which is enforced by Black.
23-
W503 ; ignore linebreak before binary operator which is enforced by Black.
24-
PT006 ; ignore that parametrizing tests with tuple argument names is preferred.
25-
PT023 ; ignores parentheses at the end of markers.
26-
max-line-length = 88
27-
warn-symbols =
28-
pytest.mark.wip = Remove 'wip' mark for tests.
29-
3018
[pytest]
3119
testpaths =
3220
src

0 commit comments

Comments
 (0)