mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2025-08-10 15:04:52 +03:00
Fix Black formatting violations
This commit is contained in:
parent
7f6391890e
commit
1f188c8481
|
@ -20,7 +20,7 @@ cd my_awesome_project
|
||||||
docker-compose -f local.yml run django mypy my_awesome_project
|
docker-compose -f local.yml run django mypy my_awesome_project
|
||||||
|
|
||||||
# Run black with --check option
|
# Run black with --check option
|
||||||
docker-compose -f local.yml run django black --check --diff --exclude 'migrations' ./
|
docker-compose -f local.yml run django black --check --diff --exclude 'migrations' my_awesome_project
|
||||||
|
|
||||||
# run the project's tests
|
# run the project's tests
|
||||||
docker-compose -f local.yml run django pytest
|
docker-compose -f local.yml run django pytest
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% if cookiecutter.use_celery == 'y' %}
|
{% if cookiecutter.use_celery == 'y' -%}
|
||||||
import os
|
import os
|
||||||
from celery import Celery
|
from celery import Celery
|
||||||
from django.apps import apps, AppConfig
|
from django.apps import apps, AppConfig
|
||||||
|
@ -7,26 +7,28 @@ from django.conf import settings
|
||||||
|
|
||||||
if not settings.configured:
|
if not settings.configured:
|
||||||
# set the default Django settings module for the 'celery' program.
|
# set the default Django settings module for the 'celery' program.
|
||||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings.local') # pragma: no cover
|
os.environ.setdefault(
|
||||||
|
"DJANGO_SETTINGS_MODULE", "config.settings.local"
|
||||||
|
) # pragma: no cover
|
||||||
|
|
||||||
|
|
||||||
app = Celery('{{cookiecutter.project_slug}}')
|
app = Celery("{{cookiecutter.project_slug}}")
|
||||||
# Using a string here means the worker will not have to
|
# Using a string here means the worker will not have to
|
||||||
# pickle the object when using Windows.
|
# pickle the object when using Windows.
|
||||||
# - namespace='CELERY' means all celery-related configuration keys
|
# - namespace='CELERY' means all celery-related configuration keys
|
||||||
# should have a `CELERY_` prefix.
|
# should have a `CELERY_` prefix.
|
||||||
app.config_from_object('django.conf:settings', namespace='CELERY')
|
app.config_from_object("django.conf:settings", namespace="CELERY")
|
||||||
|
|
||||||
|
|
||||||
class CeleryAppConfig(AppConfig):
|
class CeleryAppConfig(AppConfig):
|
||||||
name = '{{cookiecutter.project_slug}}.taskapp'
|
name = "{{cookiecutter.project_slug}}.taskapp"
|
||||||
verbose_name = 'Celery Config'
|
verbose_name = "Celery Config"
|
||||||
|
|
||||||
def ready(self):
|
def ready(self):
|
||||||
installed_apps = [app_config.name for app_config in apps.get_app_configs()]
|
installed_apps = [app_config.name for app_config in apps.get_app_configs()]
|
||||||
app.autodiscover_tasks(lambda: installed_apps, force=True)
|
app.autodiscover_tasks(lambda: installed_apps, force=True)
|
||||||
|
{%- if cookiecutter.use_sentry == 'y' %}
|
||||||
|
|
||||||
{% if cookiecutter.use_sentry == 'y' -%}
|
|
||||||
if hasattr(settings, 'RAVEN_CONFIG'):
|
if hasattr(settings, 'RAVEN_CONFIG'):
|
||||||
# Celery signal registration
|
# Celery signal registration
|
||||||
{% if cookiecutter.use_pycharm == 'y' -%}
|
{% if cookiecutter.use_pycharm == 'y' -%}
|
||||||
|
@ -51,7 +53,7 @@ class CeleryAppConfig(AppConfig):
|
||||||
|
|
||||||
@app.task(bind=True)
|
@app.task(bind=True)
|
||||||
def debug_task(self):
|
def debug_task(self):
|
||||||
print(f'Request: {self.request!r}') # pragma: no cover
|
print(f"Request: {self.request!r}") # pragma: no cover
|
||||||
{% else %}
|
{% else %}
|
||||||
# Use this as a starting point for your project with celery.
|
# Use this as a starting point for your project with celery.
|
||||||
# If you are not using celery, you can remove this app
|
# If you are not using celery, you can remove this app
|
||||||
|
|
|
@ -7,12 +7,10 @@ from django.http import HttpRequest
|
||||||
|
|
||||||
|
|
||||||
class AccountAdapter(DefaultAccountAdapter):
|
class AccountAdapter(DefaultAccountAdapter):
|
||||||
|
|
||||||
def is_open_for_signup(self, request: HttpRequest):
|
def is_open_for_signup(self, request: HttpRequest):
|
||||||
return getattr(settings, "ACCOUNT_ALLOW_REGISTRATION", True)
|
return getattr(settings, "ACCOUNT_ALLOW_REGISTRATION", True)
|
||||||
|
|
||||||
|
|
||||||
class SocialAccountAdapter(DefaultSocialAccountAdapter):
|
class SocialAccountAdapter(DefaultSocialAccountAdapter):
|
||||||
|
|
||||||
def is_open_for_signup(self, request: HttpRequest, sociallogin: Any):
|
def is_open_for_signup(self, request: HttpRequest, sociallogin: Any):
|
||||||
return getattr(settings, "ACCOUNT_ALLOW_REGISTRATION", True)
|
return getattr(settings, "ACCOUNT_ALLOW_REGISTRATION", True)
|
||||||
|
|
|
@ -6,7 +6,6 @@ User = get_user_model()
|
||||||
|
|
||||||
|
|
||||||
class UserChangeForm(forms.UserChangeForm):
|
class UserChangeForm(forms.UserChangeForm):
|
||||||
|
|
||||||
class Meta(forms.UserChangeForm.Meta):
|
class Meta(forms.UserChangeForm.Meta):
|
||||||
model = User
|
model = User
|
||||||
|
|
||||||
|
|
|
@ -19,9 +19,7 @@ class UserFactory(DjangoModelFactory):
|
||||||
digits=True,
|
digits=True,
|
||||||
upper_case=True,
|
upper_case=True,
|
||||||
lower_case=True,
|
lower_case=True,
|
||||||
).generate(
|
).generate(extra_kwargs={})
|
||||||
extra_kwargs={}
|
|
||||||
)
|
|
||||||
self.set_password(password)
|
self.set_password(password)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
|
@ -7,7 +7,6 @@ pytestmark = pytest.mark.django_db
|
||||||
|
|
||||||
|
|
||||||
class TestUserCreationForm:
|
class TestUserCreationForm:
|
||||||
|
|
||||||
def test_clean_username(self):
|
def test_clean_username(self):
|
||||||
# A user with proto_user params does not exist yet.
|
# A user with proto_user params does not exist yet.
|
||||||
proto_user = UserFactory.build()
|
proto_user = UserFactory.build()
|
||||||
|
|
|
@ -40,7 +40,6 @@ class TestUserUpdateView:
|
||||||
|
|
||||||
|
|
||||||
class TestUserRedirectView:
|
class TestUserRedirectView:
|
||||||
|
|
||||||
def test_get_redirect_url(
|
def test_get_redirect_url(
|
||||||
self, user: settings.AUTH_USER_MODEL, request_factory: RequestFactory
|
self, user: settings.AUTH_USER_MODEL, request_factory: RequestFactory
|
||||||
):
|
):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user