mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2025-03-27 13:04:23 +03:00
Run Ruff pre-commit hook
This commit is contained in:
parent
33a1cd7946
commit
3ccfc21411
|
@ -188,7 +188,7 @@ latex_documents = [
|
|||
"cookiecutter-django Documentation",
|
||||
"cookiecutter-django",
|
||||
"manual",
|
||||
)
|
||||
),
|
||||
]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
|
@ -223,7 +223,7 @@ man_pages = [
|
|||
"Cookiecutter Django documentation",
|
||||
["Daniel Roy Greenfeld"],
|
||||
1,
|
||||
)
|
||||
),
|
||||
]
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
|
@ -242,9 +242,9 @@ texinfo_documents = [
|
|||
"Cookiecutter Django documentation",
|
||||
"Daniel Roy Greenfeld",
|
||||
"Cookiecutter Django",
|
||||
"A Cookiecutter template for creating production-ready " "Django projects quickly.",
|
||||
"A Cookiecutter template for creating production-ready Django projects quickly.",
|
||||
"Miscellaneous",
|
||||
)
|
||||
),
|
||||
]
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
|
|
|
@ -39,7 +39,7 @@ def remove_custom_user_manager_files():
|
|||
"{{cookiecutter.project_slug}}",
|
||||
"users",
|
||||
"managers.py",
|
||||
)
|
||||
),
|
||||
)
|
||||
os.remove(
|
||||
os.path.join(
|
||||
|
@ -47,7 +47,7 @@ def remove_custom_user_manager_files():
|
|||
"users",
|
||||
"tests",
|
||||
"test_managers.py",
|
||||
)
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
@ -132,7 +132,7 @@ def update_package_json(remove_dev_deps=None, remove_keys=None, scripts=None):
|
|||
remove_dev_deps = remove_dev_deps or []
|
||||
remove_keys = remove_keys or []
|
||||
scripts = scripts or {}
|
||||
with open("package.json", mode="r") as fd:
|
||||
with open("package.json") as fd:
|
||||
content = json.load(fd)
|
||||
for package_name in remove_dev_deps:
|
||||
content["devDependencies"].pop(package_name)
|
||||
|
@ -196,7 +196,7 @@ def handle_js_runner(choice, use_docker, use_async):
|
|||
"dev": "concurrently npm:dev:*",
|
||||
"dev:webpack": "webpack serve --config webpack/dev.config.js",
|
||||
"dev:django": dev_django_cmd,
|
||||
}
|
||||
},
|
||||
)
|
||||
else:
|
||||
remove_dev_deps.append("concurrently")
|
||||
|
@ -205,7 +205,7 @@ def handle_js_runner(choice, use_docker, use_async):
|
|||
|
||||
|
||||
def remove_prettier_pre_commit():
|
||||
with open(".pre-commit-config.yaml", "r") as fd:
|
||||
with open(".pre-commit-config.yaml") as fd:
|
||||
content = fd.readlines()
|
||||
|
||||
removing = False
|
||||
|
@ -286,7 +286,7 @@ def set_flag(file_path, flag, value=None, formatted=None, *args, **kwargs):
|
|||
if random_string is None:
|
||||
print(
|
||||
"We couldn't find a secure pseudo-random number generator on your "
|
||||
"system. Please, make sure to manually {} later.".format(flag)
|
||||
f"system. Please, make sure to manually {flag} later.",
|
||||
)
|
||||
random_string = flag
|
||||
if formatted is not None:
|
||||
|
@ -464,7 +464,7 @@ def main():
|
|||
print(
|
||||
INFO + ".env(s) are only utilized when Docker Compose and/or "
|
||||
"Heroku support is enabled so keeping them does not make sense "
|
||||
"given your current setup." + TERMINATOR
|
||||
"given your current setup." + TERMINATOR,
|
||||
)
|
||||
remove_envs_and_associated_files()
|
||||
else:
|
||||
|
@ -491,7 +491,7 @@ def main():
|
|||
if "{{ cookiecutter.cloud_provider }}" == "None" and "{{ cookiecutter.use_docker }}".lower() == "n":
|
||||
print(
|
||||
WARNING + "You chose to not use any cloud providers nor Docker, "
|
||||
"media files won't be served in production." + TERMINATOR
|
||||
"media files won't be served in production." + TERMINATOR,
|
||||
)
|
||||
|
||||
if "{{ cookiecutter.use_celery }}".lower() == "n":
|
||||
|
|
|
@ -16,9 +16,9 @@ SUCCESS = "\x1b[1;32m [SUCCESS]: "
|
|||
|
||||
project_slug = "{{ cookiecutter.project_slug }}"
|
||||
if hasattr(project_slug, "isidentifier"):
|
||||
assert project_slug.isidentifier(), "'{}' project slug is not a valid Python identifier.".format(project_slug)
|
||||
assert project_slug.isidentifier(), f"'{project_slug}' project slug is not a valid Python identifier."
|
||||
|
||||
assert project_slug == project_slug.lower(), "'{}' project slug should be all lowercase".format(project_slug)
|
||||
assert project_slug == project_slug.lower(), f"'{project_slug}' project slug should be all lowercase"
|
||||
|
||||
assert "\\" not in "{{ cookiecutter.author_name }}", "Don't include backslashes in author name."
|
||||
|
||||
|
|
|
@ -14,7 +14,9 @@ import re
|
|||
import sys
|
||||
from collections.abc import Iterable
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING, Any, NamedTuple
|
||||
from typing import TYPE_CHECKING
|
||||
from typing import Any
|
||||
from typing import NamedTuple
|
||||
|
||||
import requests
|
||||
from github import Github
|
||||
|
@ -221,8 +223,7 @@ class GitHubManager:
|
|||
if supported_dj_versions:
|
||||
if any(v >= needed_dj_version for v in supported_dj_versions):
|
||||
return package_info["info"]["version"], "✅"
|
||||
else:
|
||||
return "", "❌"
|
||||
return "", "❌"
|
||||
|
||||
# Django classifier DNE; assume it isn't a Django lib
|
||||
# Great exceptions include pylint-django, where we need to do this manually...
|
||||
|
|
|
@ -54,7 +54,7 @@ def main() -> None:
|
|||
|
||||
# Run uv lock
|
||||
uv_lock_path = ROOT / "uv.lock"
|
||||
subprocess.run(["uv", "lock", "--no-upgrade"], cwd=ROOT)
|
||||
subprocess.run(["uv", "lock", "--no-upgrade"], cwd=ROOT, check=False)
|
||||
|
||||
# Commit changes, create tag and push
|
||||
update_git_repo([changelog_path, setup_py_path, uv_lock_path], release)
|
||||
|
|
|
@ -315,7 +315,7 @@ def test_gitlab_invokes_precommit_and_pytest(cookies, context, use_docker, expec
|
|||
try:
|
||||
gitlab_config = yaml.safe_load(gitlab_yml)
|
||||
assert gitlab_config["precommit"]["script"] == [
|
||||
"pre-commit run --show-diff-on-failure --color=always --all-files"
|
||||
"pre-commit run --show-diff-on-failure --color=always --all-files",
|
||||
]
|
||||
assert gitlab_config["pytest"]["script"] == [expected_test_script]
|
||||
except yaml.YAMLError as e:
|
||||
|
@ -401,7 +401,7 @@ def test_trim_domain_email(cookies, context):
|
|||
"use_docker": "y",
|
||||
"domain_name": " example.com ",
|
||||
"email": " me@example.com ",
|
||||
}
|
||||
},
|
||||
)
|
||||
result = cookies.bake(extra_context=context)
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import pytest
|
|||
from hooks.post_gen_project import append_to_gitignore_file
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def working_directory(tmp_path):
|
||||
prev_cwd = Path.cwd()
|
||||
os.chdir(tmp_path)
|
||||
|
|
Loading…
Reference in New Issue
Block a user