Skip to content

Commit 26efcfa

Browse files
authored
Merge pull request #91 from smkent/manage-cookie
Update project template cruft
2 parents c4899ec + 91b6a89 commit 26efcfa

6 files changed

Lines changed: 21 additions & 12 deletions

File tree

.cruft.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"template": ".",
3-
"commit": "757202d63c5e720d55fbd434d89ab8f45cd0c6bb",
3+
"commit": "c4899ec894c43ac32a763a480b6fb0f209503ede",
44
"context": {
55
"cookiecutter": {
66
"project_name": "Cookiecutter template for new Python projects",

.pre-commit-config.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ repos:
3434
- flake8-pyproject
3535
- flake8-simplify
3636
- pep8-naming
37+
- repo: https://github.com/pycqa/autoflake
38+
rev: v2.0.1
39+
hooks:
40+
- id: autoflake
41+
- repo: https://github.com/asottile/pyupgrade
42+
rev: v3.3.1
43+
hooks:
44+
- id: pyupgrade
3745
- repo: local
3846
hooks:
3947
- id: mypy

cookie_python/manage/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import sys
55
from enum import Enum
66
from pathlib import Path
7-
from typing import Callable, Optional
7+
from typing import Callable
88

99
from loguru import logger
1010

@@ -28,7 +28,7 @@ class Action(str, Enum):
2828
def __new__(
2929
cls,
3030
value: str,
31-
func: Optional[Callable[[argparse.Namespace], None]] = None,
31+
func: Callable[[argparse.Namespace], None] | None = None,
3232
description: str = "",
3333
) -> Action:
3434
obj = str.__new__(cls, value)

cookie_python/manage/repo.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from functools import cached_property
1010
from pathlib import Path
1111
from types import TracebackType
12-
from typing import Any, Optional
12+
from typing import Any
1313

1414
import loguru
1515

@@ -30,9 +30,9 @@ def __enter__(self) -> RepoSandbox:
3030

3131
def __exit__(
3232
self,
33-
exc_type: Optional[type[BaseException]] = None,
34-
exc_val: Optional[BaseException] = None,
35-
exc_tb: Optional[TracebackType] = None,
33+
exc_type: type[BaseException] | None = None,
34+
exc_val: BaseException | None = None,
35+
exc_tb: TracebackType | None = None,
3636
) -> None:
3737
self._stack.close()
3838

@@ -58,7 +58,7 @@ def create_release(self, tag: str) -> None:
5858
)
5959

6060
@cached_property
61-
def logger(self) -> "loguru.Logger":
61+
def logger(self) -> loguru.Logger:
6262
return loguru.logger.bind(repo=self.repo.full_name)
6363

6464
@cached_property

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ help = "Check all files"
6666
[tool.poe.tasks.pytest]
6767
cmd = "pytest"
6868
help = "Run unit tests with pytest"
69+
env = { PYTHON_KEYRING_BACKEND = "keyring.backends.null.Keyring" }
6970

7071
[tool.poe.tasks.test]
7172
sequence = ["lint", "pytest"]

tests/test_template.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ def test_project_license(cookies: Any, project_license: str) -> None:
6868
if project_license in ("MIT", "BSD-3-Clause"):
6969
# Compare copyright line separately
7070
if project_license == "MIT":
71-
expected_copyright = "Copyright (c) {0} Ness".format(
71+
expected_copyright = "Copyright (c) {} Ness".format(
7272
datetime.date.today().year
7373
)
7474
elif project_license == "BSD-3-Clause":
75-
expected_copyright = "Copyright (c) {0}, Ness".format(
75+
expected_copyright = "Copyright (c) {}, Ness".format(
7676
datetime.date.today().year
7777
)
7878
assert license_data.splitlines()[0] == expected_copyright
@@ -171,11 +171,11 @@ def test_rendered_readme(
171171
),
172172
)
173173

174-
with open(os.path.join(result.project_path, "README.md"), "r") as f:
174+
with open(os.path.join(result.project_path, "README.md")) as f:
175175
readme = f.read()
176176
if opt_update_expected_outputs:
177177
with open(expected_content_file, "w") as f:
178178
f.write(readme)
179179

180-
with open(expected_content_file, "r") as f:
180+
with open(expected_content_file) as f:
181181
assert readme == f.read()

0 commit comments

Comments
 (0)