Skip to content

Commit 4fb2bba

Browse files
committed
fix: some smaller fixes
Signed-off-by: Henry Schreiner <[email protected]>
1 parent d09a3b2 commit 4fb2bba

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,13 @@ repos:
4646
rev: "v1.18.2"
4747
hooks:
4848
- id: mypy
49-
files: "(src|tests)"
49+
files: "(src|tests|noxfile.py)"
5050
args: []
5151
additional_dependencies:
5252
- click
5353
- markdown-it-py
5454
- pytest
55+
- nox
5556
- orjson
5657
- repo-review>=0.10.6
5758
- rich

noxfile.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
from __future__ import annotations
1414

1515
import difflib
16-
import email.message
16+
import email.parser
17+
import email.policy
1718
import functools
1819
import json
1920
import os
@@ -238,7 +239,9 @@ def tests(session: nox.Session, backend: str, vcs: bool) -> None:
238239
"-c",
239240
f'import importlib.metadata as m; print(m.version("{name}"))',
240241
silent=True,
241-
).strip()
242+
)
243+
assert version
244+
version = version.strip()
242245
expected_version = get_expected_version(backend, vcs)
243246
assert version == expected_version, f"{version=} != {expected_version=}"
244247

@@ -292,7 +295,9 @@ def dist(session: nox.Session, backend: str, vcs: bool) -> None:
292295
(metadata_path,) = (
293296
n for n in names if n.endswith("PKG-INFO") and "egg-info" not in n
294297
)
295-
with tf.extractfile(metadata_path) as mfile:
298+
efile = tf.extractfile(metadata_path)
299+
assert efile
300+
with efile as mfile:
296301
info = mfile.read().decode("utf-8")
297302
if "License-Expression: BSD-3-Clause" not in info:
298303
msg = "License expression not found in METADATA"
@@ -307,7 +312,11 @@ def dist(session: nox.Session, backend: str, vcs: bool) -> None:
307312
metadata_path = next(iter(n for n in names if n.endswith("METADATA")))
308313
with zf.open(metadata_path) as mfile:
309314
txt = mfile.read()
310-
license_fields = email.message.EmailMessage(txt).get_all("License", [])
315+
license_fields = (
316+
email.parser.BytesParser(policy=email.policy.default)
317+
.parsebytes(txt)
318+
.get_all("License", [])
319+
)
311320
if license_fields:
312321
msg = f"Should not have anything in the License slot, got {license_fields}"
313322
session.error(msg)
@@ -408,14 +417,16 @@ def pc_bump(session: nox.Session) -> None:
408417

409418
for proj, (old_version, space) in old_versions.items():
410419
if proj not in versions:
411-
versions[proj] = session.run(
420+
versions_proj = session.run(
412421
"lastversion",
413422
"--at=github",
414423
"--format=tag",
415424
"--exclude=~alpha|beta|rc",
416425
proj,
417426
silent=True,
418-
).strip()
427+
)
428+
assert versions_proj
429+
versions[proj] = versions_proj.strip()
419430
new_version = versions[proj]
420431

421432
after = PC_REPL_LINE.format(proj, new_version, space, '"')
@@ -454,7 +465,7 @@ def get_latest_version_tag(repo: str, old_version: str) -> dict[str, Any] | None
454465
and x["name"].startswith("v") == old_version.startswith("v")
455466
]
456467
if tags:
457-
return tags[0]
468+
return tags[0] # type: ignore[no-any-return]
458469
return None
459470

460471

{{cookiecutter.project_name}}/.pre-commit-config.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ repos:
99
rev: "1.20.0"
1010
hooks:
1111
- id: blacken-docs
12-
additional_dependencies: [black==24.*]
12+
additional_dependencies: [black==25.*]
1313

1414
- repo: https://github.com/pre-commit/pre-commit-hooks
1515
rev: "v6.0.0"
@@ -62,9 +62,10 @@ repos:
6262
rev: "v1.18.2"
6363
hooks:
6464
- id: mypy
65-
files: src|tests
65+
files: src|tests|noxfile.py
6666
args: []
6767
additional_dependencies:
68+
- nox
6869
- pytest
6970

7071
- repo: https://github.com/codespell-project/codespell

0 commit comments

Comments
 (0)