diff --git a/.github/ISSUE_TEMPLATE/bug.md b/.github/ISSUE_TEMPLATE/bug.md index 304e9b34..e984493d 100644 --- a/.github/ISSUE_TEMPLATE/bug.md +++ b/.github/ISSUE_TEMPLATE/bug.md @@ -12,11 +12,11 @@ labels: bug -* Host system configuration: +* Host system configuration: * Version of cookiecutter CLI (get it with `cookiecutter --version`): * OS name and version: - On Linux, run + On Linux, run ```bash lsb_release -a 2> /dev/null || cat /etc/redhat-release 2> /dev/null || cat /etc/*-release 2> /dev/null || cat /etc/issue 2> /dev/null ``` @@ -25,7 +25,7 @@ labels: bug ```bash sw_vers ``` - + On Windows, via CMD, run ``` systeminfo | findstr /B /C:"OS Name" /C:"OS Version" @@ -34,7 +34,7 @@ labels: bug ```bash # Insert here the OS name and version - + ``` * Python version, run `python3 -V`: diff --git a/.github/ISSUE_TEMPLATE/question.md b/.github/ISSUE_TEMPLATE/question.md index 2ba657d5..e39803fa 100644 --- a/.github/ISSUE_TEMPLATE/question.md +++ b/.github/ISSUE_TEMPLATE/question.md @@ -6,6 +6,6 @@ labels: question First, make sure to examine [the docs](https://cookiecutter-django.readthedocs.io/en/latest/). If that doesn't help, we recommend one of these 3 main channels: -- If your issue is related to Django + something else but was generated with cookiecutter-django, the best is to post a question on [StackOverflow](https://stackoverflow.com/questions/tagged/cookiecutter-django) tagged with `cookiecutter-django`, you would get more visibility from other communities as well. +- If your issue is related to Django + something else but was generated with cookiecutter-django, the best is to post a question on [StackOverflow](https://stackoverflow.com/questions/tagged/cookiecutter-django) tagged with `cookiecutter-django`, you would get more visibility from other communities as well. - Join us on [Discord](https://discord.gg/bTfDa6Zz) and ask around. - Start [a discussion](https://github.com/cookiecutter/cookiecutter-django/discussions) on our project's GitHub. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 5559e62f..eb7134a8 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -12,7 +12,7 @@ Checklist: ## Rationale - diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dc415bee..85c4cedc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,16 +5,20 @@ on: pull_request: jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: "3.9" + cache: pip + - name: Run pre-commit + uses: pre-commit/action@v2.0.3 + tox: runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - tox-env: - - py39 - - black-template - - name: "tox env ${{ matrix.tox-env }}" + name: "Test with tox" steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 @@ -25,8 +29,8 @@ jobs: run: | python -m pip install -U pip python -m pip install -U tox - - name: Tox ${{ matrix.tox-env }} - run: tox -e ${{ matrix.tox-env }} + - name: Run tox + run: tox -e py39 docker: runs-on: ubuntu-latest diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..c9fcab24 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,29 @@ +exclude: "{{cookiecutter.project_slug}}" +default_stages: [commit] + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.0.1 + hooks: + - id: trailing-whitespace + - id: check-yaml + + - repo: https://github.com/psf/black + rev: 21.11b1 + hooks: + - id: black + + - repo: https://github.com/PyCQA/isort + rev: 5.10.1 + hooks: + - id: isort + + - repo: https://github.com/PyCQA/flake8 + rev: 4.0.1 + hooks: + - id: flake8 + +ci: + autoupdate_schedule: weekly + skip: [] + submodules: false diff --git a/CHANGELOG.md b/CHANGELOG.md index 781a0aa3..94115000 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1066,7 +1066,7 @@ All enhancements and patches to Cookiecutter Django will be documented in this f ### Removed - Remove the user list view (@browniebroke) -### Fixed +### Fixed - Static storage default ACL (@browniebroke) ## [2019-05-17] @@ -1102,7 +1102,7 @@ All enhancements and patches to Cookiecutter Django will be documented in this f ## [2019-03-11] ### Changed - Sentry integration from Raven to Sentry-SDK (@gfabricio) -- Made Redis config conditional on Celery locally (@demestav) +- Made Redis config conditional on Celery locally (@demestav) ## [2019-03-11] ### Added @@ -1171,7 +1171,7 @@ All enhancements and patches to Cookiecutter Django will be documented in this f ### Changed - Test commands to use pytest (@jcass77) -### Removed +### Removed - Some hacks leftovers from Bootstrap v4 beta in `project.js` (@hendrikschneider) ## [2018-07-12] diff --git a/docs/conf.py b/docs/conf.py index 8c4b2816..f55bcb81 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -7,10 +7,7 @@ # # All configuration values have a default; values that are commented out # serve to show the default. - from datetime import datetime -import os -import sys now = datetime.now() @@ -242,7 +239,8 @@ 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", ) ] diff --git a/docs/deployment-on-heroku.rst b/docs/deployment-on-heroku.rst index 70929612..bab5881c 100644 --- a/docs/deployment-on-heroku.rst +++ b/docs/deployment-on-heroku.rst @@ -10,7 +10,7 @@ Run these commands to deploy the project to Heroku: .. code-block:: bash - heroku create --buildpack heroku/python + heroku create --buildpack heroku/python heroku addons:create heroku-postgresql:hobby-dev # On Windows use double quotes for the time zone, e.g. diff --git a/docs/developing-locally-docker.rst b/docs/developing-locally-docker.rst index 72999be3..17e47bfb 100644 --- a/docs/developing-locally-docker.rst +++ b/docs/developing-locally-docker.rst @@ -216,17 +216,17 @@ Increasingly it is becoming necessary to develop software in a secure environmen In order to create a secure environment, we need to have a trusted SSL certficate installed in our Docker application. #. **Let's Encrypt** - - The official line from Let’s Encrypt is: - [For local development section] ... The best option: Generate your own certificate, either self-signed or signed by a local root, and trust it in your operating system’s trust store. Then use that certificate in your local web server. See below for details. + The official line from Let’s Encrypt is: + + [For local development section] ... The best option: Generate your own certificate, either self-signed or signed by a local root, and trust it in your operating system’s trust store. Then use that certificate in your local web server. See below for details. See `letsencrypt.org - certificates-for-localhost`_ .. _`letsencrypt.org - certificates-for-localhost`: https://letsencrypt.org/docs/certificates-for-localhost/ #. **mkcert: Valid Https Certificates For Localhost** - + `mkcert`_ is a simple by design tool that hides all the arcane knowledge required to generate valid TLS certificates. It works for any hostname or IP, including localhost. It supports macOS, Linux, and Windows, and Firefox, Chrome and Java. It even works on mobile devices with a couple manual steps. See https://blog.filippo.io/mkcert-valid-https-certificates-for-localhost/ @@ -261,11 +261,11 @@ local.yml restart: always depends_on: - django - + ... #. Link the ``nginx-proxy`` to ``django`` through environment variables. - + ``django`` already has an ``.env`` file connected to it. Add the following variables. You should do this especially if you are working with a team and you want to keep your local environment details to yourself. :: diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index ede14c32..3ad0e9e5 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -5,7 +5,8 @@ NOTE: 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 +TODO: restrict Cookiecutter Django project initialization to + Python 3.x environments only """ from __future__ import print_function @@ -164,8 +165,8 @@ def set_flag(file_path, flag, value=None, formatted=None, *args, **kwargs): random_string = generate_random_string(*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) + "We couldn't find a secure pseudo-random number generator on your " + "system. Please, make sure to manually {} later.".format(flag) ) random_string = flag if formatted is not None: diff --git a/hooks/pre_gen_project.py b/hooks/pre_gen_project.py index 70c29557..3fd4131c 100644 --- a/hooks/pre_gen_project.py +++ b/hooks/pre_gen_project.py @@ -4,7 +4,8 @@ NOTE: 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 +TODO: restrict Cookiecutter Django project initialization + to Python 3.x environments only """ from __future__ import print_function @@ -39,7 +40,7 @@ if "{{ cookiecutter.use_docker }}".lower() == "n": ) yes_options, no_options = frozenset(["y"]), frozenset(["n"]) while True: - choice = raw_input().lower() + choice = raw_input().lower() # noqa: F821 if choice in yes_options: break @@ -65,7 +66,8 @@ if ( and "{{ cookiecutter.cloud_provider }}" == "None" ): print( - "You should either use Whitenoise or select a Cloud Provider to serve static files" + "You should either use Whitenoise or select a " + "Cloud Provider to serve static files" ) sys.exit(1) @@ -77,6 +79,7 @@ if ( and "{{ cookiecutter.mail_service }}" == "Amazon SES" ): print( - "You should either use AWS or select a different Mail Service for sending emails." + "You should either use AWS or select a different " + "Mail Service for sending emails." ) sys.exit(1) diff --git a/scripts/__init__.py b/scripts/__init__.py index 8b137891..e69de29b 100644 --- a/scripts/__init__.py +++ b/scripts/__init__.py @@ -1 +0,0 @@ - diff --git a/scripts/update_changelog.py b/scripts/update_changelog.py index 1ec9bde9..c3c834ee 100644 --- a/scripts/update_changelog.py +++ b/scripts/update_changelog.py @@ -85,7 +85,7 @@ def group_pulls_by_change_type( "Updated": [], } for pull in pull_requests_list: - label_names = {l.name for l in pull.labels} + label_names = {label.name for label in pull.labels} if "update" in label_names: group_name = "Updated" elif "bug" in label_names: diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 00000000..dd8f1ef3 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,7 @@ +[flake8] +exclude = docs +max-line-length = 88 + +[isort] +profile = black +known_first_party = tests,scripts,hooks diff --git a/setup.py b/setup.py index b413933c..d4b7e9a1 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,10 @@ with open("README.rst") as readme_file: setup( name="cookiecutter-django", version=version, - description="A Cookiecutter template for creating production-ready Django projects quickly.", + description=( + "A Cookiecutter template for creating production-ready " + "Django projects quickly." + ), long_description=long_description, author="Daniel Roy Greenfeld", author_email="pydanny@gmail.com", diff --git a/tests/test_cookiecutter_generation.py b/tests/test_cookiecutter_generation.py index bb9ba69f..dd4fc34e 100755 --- a/tests/test_cookiecutter_generation.py +++ b/tests/test_cookiecutter_generation.py @@ -2,10 +2,10 @@ import os import re import pytest -from cookiecutter.exceptions import FailedHookException import sh import yaml from binaryornot.check import is_binary +from cookiecutter.exceptions import FailedHookException PATTERN = r"{{(\s?cookiecutter)[.](.*?)}}" RE_OBJ = re.compile(PATTERN)