Skip to content

Commit

Permalink
Merge pull request #79 from django-stars/refreshing-skeleton
Browse files Browse the repository at this point in the history
Refreshing skeleton
  • Loading branch information
SergeyKubrak authored May 17, 2024
2 parents fcb1e0c + bb88d37 commit b2333ad
Show file tree
Hide file tree
Showing 14 changed files with 25 additions and 60 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ Fast start achieved by using docker and docker compose.
* Docker support using [docker-compose](https://docs.docker.com/compose/) configuration for local development (incl. [Postgres](https://www.postgresql.org/), [Redis](https://redis.io/) & [MailPit](https://github.com/axllent/mailpit) for testing emails).
* Requirements management with [poetry](https://python-poetry.org/).
* [pytest](https://docs.pytest.org/) configuration.
* Code formatting with [Black](https://black.readthedocs.io/).
* Checking code with [Ruff](https://beta.ruff.rs/docs/) - which includes _flake8_, _isort_, _bandit_, _pylint_ etc.
* Code formatting with [Ruff](https://docs.astral.sh/ruff/formatter/).
* Checking code with [Ruff](https://docs.astral.sh/ruff/) - which includes _flake8_, _isort_, _bandit_, _pylint_ etc.
* [Pre-commit](https://pre-commit.com/) hook for running test & linters on each commit.
* Integration with [Sentry](https://sentry.io/).

Expand Down
6 changes: 3 additions & 3 deletions cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"project_name": "awesome",
"project_slug": "{{ cookiecutter.project_name.lower()|replace(' ', '_')|replace('-', '_')|replace('.', '_')|trim() }}",
"domain_name": "example.com",
"python_version": "3.10",
"postgresql_version": "15.0",
"redis_version": "7.0",
"python_version": "3.12",
"postgresql_version": "16.3",
"redis_version": "7.2",
"__env_prefix": "{{ cookiecutter.project_slug | upper() }}_",
"__docker_service_prefix": "{{ cookiecutter.project_name.lower()|replace(' ', '-')|replace('.', '_')|trim() }}",
"__db_name": "{{ cookiecutter.project_slug | lower() }}_db",
Expand Down
6 changes: 0 additions & 6 deletions {{ cookiecutter.project_slug }}/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@ repos:
- id: codespell

# API
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
args: ["--config", "./api/pyproject.toml", . ]
pass_filenames: false
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.265
hooks:
Expand Down
2 changes: 1 addition & 1 deletion {{ cookiecutter.project_slug }}/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# {{ cookiecutter.project_name }}

[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Code style: Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://docs.astral.sh/ruff/formatter/)

### List of services: ###

Expand Down
4 changes: 2 additions & 2 deletions {{ cookiecutter.project_slug }}/api/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ collectstatic:
python manage.py collectstatic --noinput

check:
black . --check \
ruff format . --check \
&& ruff check . \
&& safety check \
&& make check-migrations \

check-fix:
black .
ruff format .
ruff check --fix-only --show-fixes --statistics .

run:migrate collectstatic
Expand Down
40 changes: 9 additions & 31 deletions {{ cookiecutter.project_slug }}/api/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ boto3 = "^1.26"
[tool.poetry.group.dev.dependencies]
Pygments = "*"
bandit = "*"
black = "*"
ruff = "*"
coverage = { version = "*", extras = ["toml"] }
django-debug-toolbar = "*"
Expand All @@ -44,34 +43,14 @@ safety = "*"
DJANGO_SETTINGS_MODULE = "{{ cookiecutter.project_slug }}.settings"
python_files = ["tests.py", "test_*.py", "*_test.py"]

[tool.black]
line-length = 120
target-version = ["py{{ cookiecutter.python_version.lower()|replace('.', '') }}",]
exclude = '''
/(
\.eggs
| \.git
| \.hg
| \.mypy_cache
| \.tox
| \.env
| \.venv
| _build
| buck-out
| build
| dist
| node_modules
)/
'''

[tool.ruff]
# Enable pycodestyle (`E`), Pyflakes (`F`), Isort (`I`), Bandit (`S`) and flake8 Django (`DJ`) codes.
select = ["E", "F", "I", "S", "DJ"]
ignore = []
lint.select = ["E", "F", "I", "S", "DJ"]
lint.ignore = []

# Allow autofix for all enabled rules (when `--fix`) is provided.
fixable = ["A", "B", "C", "D", "E", "F", "G", "I", "N", "Q", "S", "T", "W", "ANN", "ARG", "BLE", "COM", "DJ", "DTZ", "EM", "ERA", "EXE", "FBT", "ICN", "INP", "ISC", "NPY", "PD", "PGH", "PIE", "PL", "PT", "PTH", "PYI", "RET", "RSE", "RUF", "SIM", "SLF", "TCH", "TID", "TRY", "UP", "YTT"]
unfixable = []
lint.fixable = ["A", "B", "C", "D", "E", "F", "G", "I", "N", "Q", "S", "T", "W", "ANN", "ARG", "BLE", "COM", "DJ", "DTZ", "EM", "ERA", "EXE", "FBT", "ICN", "INP", "ISC", "NPY", "PD", "PGH", "PIE", "PL", "PT", "PTH", "PYI", "RET", "RSE", "RUF", "SIM", "SLF", "TCH", "TID", "TRY", "UP", "YTT"]
lint.unfixable = []

# Exclude a variety of commonly ignored directories.
exclude = [
Expand All @@ -97,31 +76,30 @@ exclude = [
"venv",
]

# Same as Black.
line-length = 120

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
lint.dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
target-version = "py{{ cookiecutter.python_version.lower()|replace('.', '') }}"

[tool.ruff.mccabe]
[tool.ruff.lint.mccabe]
# Unlike Flake8, default to a complexity level of 10.
max-complexity = 10

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401", "F403"]
"conftest*" = ["F403"]
"test_*.py" = ["S"]
"tests.py" = ["S"]
"*_test.py" = ["S"]

[tool.ruff.isort]
[tool.ruff.lint.isort]
lines-between-types = 1
lines-after-imports = 2
known-first-party=['{{ cookiecutter.project_slug }}']
section-order= ['future', 'standard-library', 'third-party', 'django', 'first-party', 'local-folder']

[tool.ruff.isort.sections]
[tool.ruff.lint.isort.sections]
"django" = ["django"]

[tool.coverage.run]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from drf_spectacular.utils import extend_schema, OpenApiResponse
from drf_spectacular.utils import OpenApiResponse, extend_schema
from rest_framework import status
from rest_framework.generics import GenericAPIView
from rest_framework.permissions import IsAuthenticated
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from drf_spectacular.utils import extend_schema, OpenApiResponse
from drf_spectacular.utils import OpenApiResponse, extend_schema
from rest_framework import status
from rest_framework.generics import CreateAPIView
from rest_framework.permissions import IsAuthenticated
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from drf_spectacular.utils import extend_schema, OpenApiResponse
from drf_spectacular.utils import OpenApiResponse, extend_schema
from rest_framework import status
from rest_framework.generics import GenericAPIView

Expand All @@ -9,9 +9,7 @@
class RegistrationAPIView(GenericAPIView):
serializer_class = RegistrationSerializer

@extend_schema(
summary="Registration", tags=["Accounts"], responses={status.HTTP_204_NO_CONTENT: OpenApiResponse()}
)
@extend_schema(summary="Registration", tags=["Accounts"], responses={status.HTTP_204_NO_CONTENT: OpenApiResponse()})
def post(self, request):
serializer = self.get_serializer(data=request.data)
serializer.is_valid(raise_exception=True)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from drf_spectacular.utils import extend_schema_view, extend_schema, OpenApiResponse
from drf_spectacular.utils import extend_schema, extend_schema_view
from rest_framework.generics import RetrieveUpdateAPIView
from rest_framework.permissions import IsAuthenticated

Expand All @@ -17,7 +17,7 @@
patch=extend_schema(
summary="Update me",
tags=["Accounts"],
)
),
)
class UserProfileAPIView(RetrieveUpdateAPIView):
serializer_class = UserProfileSerializer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from ..environment import env


SPECTACULAR_SETTINGS = {
"TITLE": "{{ cookiecutter.project_name }} API",
"VERSION": "0.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ def rel(*path):
"endpoint_url": env.str("{{ cookiecutter.__env_prefix }}DEFAULT_FILE_STORAGE_ENDPOINT_URL"),
"custom_domain": env.str("{{ cookiecutter.__env_prefix }}DEFAULT_FILE_STORAGE_CUSTOM_DOMAIN"),
"url_protocol": env.str("{{ cookiecutter.__env_prefix }}DEFAULT_FILE_STORAGE_URL_PROTOCOL", default="https:"),

"location": env.str("{{ cookiecutter.__env_prefix }}STATICFILES_STORAGE_LOCATION", default="s"),
"file_overwrite": env.bool("{{ cookiecutter.__env_prefix }}STATICFILES_STORAGE_FILE_OVERWRITE", default=True),
}
Expand All @@ -149,7 +148,7 @@ def rel(*path):
"staticfiles": {
"BACKEND": STATICFILES_STORAGE_BACKEND,
"OPTIONS": STATICFILES_STORAGE_OPTIONS,
}
},
}

EMAIL_BACKEND = env.str(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.conf import settings
from django.contrib import admin
from django.urls import include, path, re_path
from django.urls import include, path


PLATFORM_PREFIX = "_platform"
Expand Down
1 change: 0 additions & 1 deletion {{ cookiecutter.project_slug }}/docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: '3.9'
name: '{{ cookiecutter.project_slug }}'

# Configurations shared between api service, celery and celery beat.
Expand Down

0 comments on commit b2333ad

Please sign in to comment.