From 1c1cc9ee9c29a858aaff9276486de3bef6b56068 Mon Sep 17 00:00:00 2001 From: Shupeyko Nikita Date: Thu, 13 Apr 2017 20:50:11 +0300 Subject: [PATCH] Prevent PyCharm from formatting raven and opbeat imports (#1063) * Prevent PyCharm from formatting raven and opbeat imports Since raven and opbeat are required in production only, imports might (most surely will) be wiped out during PyCharm code clean up started in other environments. * Prevent PyCharm from formatting raven and opbeat imports Since raven and opbeat are required in production only, imports might (most surely will) be wiped out during PyCharm code clean up started in other environments. * Fix line breaks and spaces * Fix linebreaks --- .../taskapp/celery.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/taskapp/celery.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/taskapp/celery.py index 8346f837..bea9768a 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/taskapp/celery.py +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/taskapp/celery.py @@ -28,9 +28,19 @@ class CeleryConfig(AppConfig): {% if cookiecutter.use_sentry_for_error_reporting == 'y' -%} if hasattr(settings, 'RAVEN_CONFIG'): # Celery signal registration +{% if cookiecutter.use_pycharm == 'y' -%} + # Since raven is required in production only, + # imports might (most surely will) be wiped out + # during PyCharm code clean up started + # in other environments. + # @formatter:off +{%- endif %} from raven import Client as RavenClient from raven.contrib.celery import register_signal as raven_register_signal from raven.contrib.celery import register_logger_signal as raven_register_logger_signal +{% if cookiecutter.use_pycharm == 'y' -%} + # @formatter:on +{%- endif %} raven_client = RavenClient(dsn=settings.RAVEN_CONFIG['DSN']) raven_register_logger_signal(raven_client) @@ -39,10 +49,20 @@ class CeleryConfig(AppConfig): {% if cookiecutter.use_opbeat == 'y' -%} if hasattr(settings, 'OPBEAT'): +{% if cookiecutter.use_pycharm == 'y' -%} + # Since opbeat is required in production only, + # imports might (most surely will) be wiped out + # during PyCharm code clean up started + # in other environments. + # @formatter:off +{%- endif %} from opbeat.contrib.django.models import client as opbeat_client from opbeat.contrib.django.models import logger as opbeat_logger from opbeat.contrib.django.models import register_handlers as opbeat_register_handlers from opbeat.contrib.celery import register_signal as opbeat_register_signal +{% if cookiecutter.use_pycharm == 'y' -%} + # @formatter:on +{%- endif %} try: opbeat_register_signal(opbeat_client)