Skip to content

Commit

Permalink
Drop Python 2 in pre/post generation hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
browniebroke committed Dec 31, 2024
1 parent c609363 commit ddeaa22
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 36 deletions.
Empty file added hooks/__init__.py
Empty file.
11 changes: 0 additions & 11 deletions hooks/post_gen_project.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
"""
NOTE:
the below code is to be maintained Python 2.x-compatible
as the whole Cookiecutter Django project initialization
can potentially be run in Python 2.x environment
(at least so we presume in `pre_gen_project.py`).
TODO: restrict Cookiecutter Django project initialization to
Python 3.x environments only
""" # noqa: INP001

import json
import os
import random
Expand Down
24 changes: 0 additions & 24 deletions hooks/pre_gen_project.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
"""
NOTE:
the below code is to be maintained Python 2.x-compatible
as the whole Cookiecutter Django project initialization
can potentially be run in Python 2.x environment.
TODO: restrict Cookiecutter Django project initialization
to Python 3.x environments only
""" # noqa: INP001

import sys

TERMINATOR = "\x1b[0m"
Expand All @@ -32,20 +22,6 @@

assert "\\" not in "{{ cookiecutter.author_name }}", "Don't include backslashes in author name." # noqa: PLR0133

if "{{ cookiecutter.use_docker }}".lower() == "n":
python_major_version = sys.version_info[0]
if python_major_version == 2: # noqa: PLR2004
yes_options, no_options = frozenset(["y"]), frozenset(["n"])
while True:
choice = raw_input().lower() # noqa: F821
if choice in yes_options:
break

elif choice in no_options:
sys.exit(1)
else:
pass

if "{{ cookiecutter.use_whitenoise }}".lower() == "n" and "{{ cookiecutter.cloud_provider }}" == "None": # noqa: PLR0133
sys.exit(1)

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ docs = [
]

[tool.ruff]
target-version = "py312"
target-version = "py39"
line-length = 119
# Exclude the template content as most files aren't parseable
extend-exclude = [
Expand Down

0 comments on commit ddeaa22

Please sign in to comment.