Skip to content

Commit 8a33eca

Browse files
pulpbotdaviddavis
authored andcommitted
Update cookiecutter
1 parent 37e80d7 commit 8a33eca

7 files changed

Lines changed: 22 additions & 25 deletions

File tree

.ci/gen_certs.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
# ///
77

88
import argparse
9-
import os
109
import sys
10+
from pathlib import Path
1111

1212
import trustme
1313

@@ -17,43 +17,41 @@ def main() -> None:
1717
parser.add_argument(
1818
"-d",
1919
"--dir",
20-
default=os.getcwd(),
20+
default=".",
2121
help="Directory where certificates and keys are written to. Defaults to cwd.",
2222
)
2323

2424
args = parser.parse_args(sys.argv[1:])
25-
cert_dir = args.dir
25+
cert_dir = Path(args.dir)
2626

27-
if not os.path.isdir(cert_dir):
27+
if not cert_dir.is_dir():
2828
raise ValueError(f"--dir={cert_dir} is not a directory")
2929

3030
key_type = trustme.KeyType["ECDSA"]
3131

3232
# Generate the CA certificate
3333
ca = trustme.CA(key_type=key_type)
3434
# Write the certificate the client should trust
35-
ca_cert_path = os.path.join(cert_dir, "ca.pem")
35+
ca_cert_path = cert_dir / "ca.pem"
3636
ca.cert_pem.write_to_path(path=ca_cert_path)
3737

3838
# Generate the server certificate
3939
server_cert = ca.issue_cert("localhost", "127.0.0.1", "::1", key_type=key_type)
4040
# Write the certificate and private key the server should use
41-
server_key_path = os.path.join(cert_dir, "server.key")
42-
server_cert_path = os.path.join(cert_dir, "server.pem")
41+
server_key_path = cert_dir / "server.key"
42+
server_cert_path = cert_dir / "server.pem"
4343
server_cert.private_key_pem.write_to_path(path=server_key_path)
44-
with open(server_cert_path, mode="w") as f:
45-
f.truncate()
44+
server_cert_path.write_text("")
4645
for blob in server_cert.cert_chain_pems:
4746
blob.write_to_path(path=server_cert_path, append=True)
4847

4948
# Generate the client certificate
5049
client_cert = ca.issue_cert("admin@example.com", common_name="admin", key_type=key_type)
5150
# Write the certificate and private key the client should use
52-
client_key_path = os.path.join(cert_dir, "client.key")
53-
client_cert_path = os.path.join(cert_dir, "client.pem")
51+
client_key_path = cert_dir / "client.key"
52+
client_cert_path = cert_dir / "client.pem"
5453
client_cert.private_key_pem.write_to_path(path=client_key_path)
55-
with open(client_cert_path, mode="w") as f:
56-
f.truncate()
54+
client_cert_path.write_text("")
5755
for blob in client_cert.cert_chain_pems:
5856
blob.write_to_path(path=client_cert_path, append=True)
5957

.ci/scripts/collect_changes.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
# ///
99

1010
import itertools
11-
import os
1211
import re
12+
from pathlib import Path
1313

1414
import tomllib
1515
from git import GitCommandError, Repo
1616
from packaging.version import parse as parse_version
1717

1818
# Read Towncrier settings
19-
with open("pyproject.toml", "rb") as fp:
19+
with Path("pyproject.toml").open("rb") as fp:
2020
tc_settings = tomllib.load(fp)["tool"]["towncrier"]
2121

2222
CHANGELOG_FILE = tc_settings.get("filename", "NEWS.rst")
@@ -74,14 +74,13 @@ def split_changelog(changelog):
7474

7575

7676
def main():
77-
repo = Repo(os.getcwd())
77+
repo = Repo(Path.cwd())
7878
remote = repo.remotes[0]
7979
branches = [ref for ref in remote.refs if re.match(r"^([0-9]+)\.([0-9]+)$", ref.remote_head)]
8080
branches.sort(key=lambda ref: parse_version(ref.remote_head), reverse=True)
8181
branches = [ref.name for ref in branches]
8282

83-
with open(CHANGELOG_FILE) as f:
84-
main_changelog = f.read()
83+
main_changelog = Path(CHANGELOG_FILE).read_text()
8584
preamble, main_changes = split_changelog(main_changelog)
8685
old_length = len(main_changes)
8786

@@ -103,7 +102,7 @@ def main():
103102
new_length = len(main_changes)
104103
if old_length < new_length:
105104
print(f"{new_length - old_length} new versions have been added.")
106-
with open(CHANGELOG_FILE, "w") as fp:
105+
with Path(CHANGELOG_FILE).open("w") as fp:
107106
fp.write(preamble)
108107
fp.writelines(change[1] for change in main_changes)
109108

.ci/scripts/pr_labels.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
def main():
2020
assert len(sys.argv) == 3
2121

22-
with open("pyproject.toml", "rb") as fp:
22+
with Path("pyproject.toml").open("rb") as fp:
2323
PYPROJECT_TOML = tomllib.load(fp)
2424
BLOCKING_REGEX = re.compile(r"DRAFT|WIP|NO\s*MERGE|DO\s*NOT\s*MERGE|EXPERIMENT")
2525
ISSUE_REGEX = re.compile(r"(?:fixes|closes)[\s:]+#(\d+)")

.ci/scripts/validate_commit_message.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import tomllib
1515
from github import Github
1616

17-
with open("pyproject.toml", "rb") as fp:
17+
with Path("pyproject.toml").open("rb") as fp:
1818
PYPROJECT_TOML = tomllib.load(fp)
1919
KEYWORDS = ["fixes", "closes"]
2020
BLOCKING_REGEX = [

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ autofix:
3535
_lint:
3636
find tests .ci -name '*.sh' -print0 | xargs -0 shellcheck -x
3737
ruff format --check --diff
38-
ruff check
38+
ruff check --output-format concise
3939
.ci/scripts/check_cli_dependencies.py
4040
.ci/scripts/check_click_for_mypy.py
4141
mypy

pulp-glue-workflow/pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ namespaces = true
3939
# This section is managed by the cookiecutter templates.
4040
"*" = ["py.typed"]
4141

42+
4243
[tool.ruff]
4344
# This section is managed by the cookiecutter templates.
4445
line-length = 100
@@ -47,6 +48,7 @@ line-length = 100
4748
# This section is managed by the cookiecutter templates.
4849
extend-select = ["I", "INT"]
4950

51+
5052
[tool.mypy]
5153
# This section is managed by the cookiecutter templates.
5254
strict = true

pyproject.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ line-length = 100
188188

189189
[tool.ruff.lint]
190190
# This section is managed by the cookiecutter templates.
191-
extend-select = ["I", "INT"]
191+
extend-select = ["I", "INT", "PTH"]
192192

193193
[tool.ruff.lint.isort]
194194
# This section is managed by the cookiecutter templates.
@@ -215,7 +215,6 @@ module = [
215215
"schema.*",
216216
]
217217
ignore_missing_imports = true
218-
219218
[dependency-groups]
220219
# This section is managed by the cookiecutter templates.
221220
dev = [
@@ -235,7 +234,6 @@ lint = [
235234
"types-toml",
236235
]
237236
test = [
238-
"jinja2>=3.1.4,<3.2",
239237
"pygments>=2.19.2",
240238
"pytest>=7.0.0,<9.1",
241239
"pytest-xdist>=3.8.0,<3.9",

0 commit comments

Comments
 (0)