Skip to content

Commit 4de7024

Browse files
committed
chore: Template upgrade
1 parent bc3fb25 commit 4de7024

File tree

5 files changed

+27
-85
lines changed

5 files changed

+27
-85
lines changed

.copier-answers.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Changes here will be overwritten by Copier
2-
_commit: 0.9.10
2+
_commit: 0.10.6
33
_src_path: gh:pawamoy/copier-pdm
44
author_email: [email protected]
55
author_fullname: Timothée Mazzucotelli

.github/workflows/ci.yml

+5-33
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,13 @@ jobs:
2525

2626
steps:
2727
- name: Checkout
28-
uses: actions/checkout@v2
28+
uses: actions/checkout@v3
2929

3030
- name: Set up PDM
31-
uses: pdm-project/setup-pdm@v2.6
31+
uses: pdm-project/setup-pdm@v3
3232
with:
3333
python-version: "3.8"
3434

35-
- name: Set cache variables
36-
id: set_variables
37-
run: |
38-
echo "::set-output name=PIP_CACHE::$(pip cache dir)"
39-
echo "::set-output name=PDM_CACHE::$(pdm config cache_dir)"
40-
41-
- name: Set up cache
42-
uses: actions/cache@v2
43-
with:
44-
path: |
45-
${{ steps.set_variables.outputs.PIP_CACHE }}
46-
${{ steps.set_variables.outputs.PDM_CACHE }}
47-
key: checks-cache
48-
4935
- name: Resolving dependencies
5036
run: pdm lock
5137

@@ -77,33 +63,19 @@ jobs:
7763
- "3.8"
7864
- "3.9"
7965
- "3.10"
80-
- "3.11-dev"
66+
- "3.11"
8167

8268
runs-on: ${{ matrix.os }}
8369

8470
steps:
8571
- name: Checkout
86-
uses: actions/checkout@v2
72+
uses: actions/checkout@v3
8773

8874
- name: Set up PDM
89-
uses: pdm-project/setup-pdm@v2.6
75+
uses: pdm-project/setup-pdm@v3
9076
with:
9177
python-version: ${{ matrix.python-version }}
9278

93-
- name: Set cache variables
94-
id: set_variables
95-
run: |
96-
echo "::set-output name=PIP_CACHE::$(pip cache dir)"
97-
echo "::set-output name=PDM_CACHE::$(pdm config cache_dir)"
98-
99-
- name: Set up cache
100-
uses: actions/cache@v2
101-
with:
102-
path: |
103-
${{ steps.set_variables.outputs.PIP_CACHE }}
104-
${{ steps.set_variables.outputs.PDM_CACHE }}
105-
key: tests-cache-${{ runner.os }}-${{ matrix.python-version }}
106-
10779
- name: Install dependencies
10880
run: pdm install --no-editable -G duty -G tests
10981

duties.py

+14-48
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
import os
55
import re
66
import sys
7-
import tempfile
8-
from contextlib import suppress
97
from io import StringIO
108
from pathlib import Path
119
from typing import List, Optional, Pattern
@@ -145,7 +143,8 @@ def check_dependencies(ctx):
145143
importlib.invalidate_caches()
146144

147145
# reload original, unpatched safety
148-
from safety.formatter import report
146+
from safety.formatter import SafetyFormatter
147+
from safety.safety import calculate_remediations
149148
from safety.safety import check as safety_check
150149
from safety.util import read_requirements
151150

@@ -159,10 +158,19 @@ def check_dependencies(ctx):
159158
# check using safety as a library
160159
def safety(): # noqa: WPS430
161160
packages = list(read_requirements(StringIO(requirements)))
162-
vulns = safety_check(packages=packages, ignore_ids="", key="", db_mirror="", cached=False, proxy={})
163-
output_report = report(vulns=vulns, full=True, checked_packages=len(packages))
161+
vulns, db_full = safety_check(packages=packages, ignore_vulns="")
162+
remediations = calculate_remediations(vulns, db_full)
163+
output_report = SafetyFormatter("text").render_vulnerabilities(
164+
announcements=[],
165+
vulnerabilities=vulns,
166+
remediations=remediations,
167+
full=True,
168+
packages=packages,
169+
)
164170
if vulns:
165171
print(output_report)
172+
return False
173+
return True
166174

167175
ctx.run(safety, title="Checking dependencies")
168176

@@ -188,49 +196,7 @@ def check_types(ctx): # noqa: WPS231
188196
Arguments:
189197
ctx: The context instance (passed automatically).
190198
"""
191-
# NOTE: the following code works around this issue:
192-
# https://github.com/python/mypy/issues/10633
193-
194-
# compute packages directory path
195-
py = f"{sys.version_info.major}.{sys.version_info.minor}"
196-
pkgs_dir = Path("__pypackages__", py, "lib").resolve()
197-
198-
# build the list of available packages
199-
packages = {}
200-
for package in pkgs_dir.glob("*"):
201-
if package.suffix not in {".dist-info", ".pth"} and package.name != "__pycache__":
202-
packages[package.name] = package
203-
204-
# handle .pth files
205-
for pth in pkgs_dir.glob("*.pth"):
206-
with suppress(OSError):
207-
for package in Path(pth.read_text().splitlines()[0]).glob("*"): # noqa: WPS440
208-
if package.suffix != ".dist-info":
209-
packages[package.name] = package
210-
211-
# create a temporary directory to assign to MYPYPATH
212-
with tempfile.TemporaryDirectory() as tmpdir:
213-
214-
# symlink the stubs
215-
ignore = set()
216-
for stubs in (path for name, path in packages.items() if name.endswith("-stubs")): # noqa: WPS335
217-
Path(tmpdir, stubs.name).symlink_to(stubs, target_is_directory=True)
218-
# try to symlink the corresponding package
219-
# see https://www.python.org/dev/peps/pep-0561/#stub-only-packages
220-
pkg_name = stubs.name.replace("-stubs", "")
221-
if pkg_name in packages:
222-
ignore.add(pkg_name)
223-
Path(tmpdir, pkg_name).symlink_to(packages[pkg_name], target_is_directory=True)
224-
225-
# create temporary mypy config to ignore stubbed packages
226-
newconfig = Path("config", "mypy.ini").read_text()
227-
newconfig += "\n" + "\n\n".join(f"[mypy-{pkg}.*]\nignore_errors=true" for pkg in ignore)
228-
tmpconfig = Path(tmpdir, "mypy.ini")
229-
tmpconfig.write_text(newconfig)
230-
231-
# set MYPYPATH and run mypy
232-
os.environ["MYPYPATH"] = tmpdir
233-
ctx.run(f"mypy --config-file {tmpconfig} {PY_SRC}", title="Type-checking", pty=PTY)
199+
ctx.run(f"mypy --config-file config/mypy.ini {PY_SRC}", title="Type-checking", pty=PTY)
234200

235201

236202
@duty(silent=True)

pyproject.toml

+6-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ build-backend = "pdm.pep517.api"
66
name = "mkdocstrings-python"
77
description = "A Python handler for mkdocstrings."
88
authors = [{name = "Timothée Mazzucotelli", email = "[email protected]"}]
9-
license-expression = "ISC"
9+
license = "ISC"
1010
readme = "README.md"
1111
requires-python = ">=3.7"
1212
keywords = []
@@ -73,6 +73,10 @@ maintain = [
7373
"git-changelog>=0.4",
7474
]
7575
quality = [
76+
# TODO: remove once importlib-metadata version conflict is resolved
77+
"importlib-metadata<5; python_version < '3.8'",
78+
"flake8>=4; python_version >= '3.8'",
79+
7680
"darglint>=1.8",
7781
"flake8-bandit>=2.1",
7882
"flake8-black>=0.2",
@@ -98,7 +102,7 @@ typing = [
98102
"types-markdown>=3.3",
99103
"types-toml>=0.10",
100104
]
101-
security = ["safety>=1.10"]
105+
security = ["safety>=2"]
102106

103107
[tool.black]
104108
line-length = 120

scripts/gen_credits.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def get_deps(base_deps):
5858
if dep_name not in deps:
5959
deps[dep_name] = {"license": get_license(dep_name), **parsed, **lock_pkgs[dep_name]}
6060
again = True
61-
61+
6262
return deps
6363

6464
dev_dependencies = get_deps(chain(*pdm.get("dev-dependencies", {}).values()))

0 commit comments

Comments
 (0)