From 14799248cd1267649f8dc6663e5bad25c5b7c759 Mon Sep 17 00:00:00 2001 From: Tomer Nosrati Date: Mon, 8 Jan 2024 03:29:46 +0200 Subject: [PATCH] Lint fixes --- .pre-commit-config.yaml | 1 + .../django/demoapp/migrations/0001_initial.py | 13 ++- examples/django/demoapp/tasks.py | 4 +- examples/django/manage.py | 4 +- examples/django/proj/__init__.py | 2 +- examples/django/proj/celery.py | 8 +- examples/django/proj/settings.py | 80 +++++++++---------- examples/django/proj/urls.py | 2 - examples/django/proj/wsgi.py | 2 +- examples/django/pytest.ini | 2 +- examples/django/requirements.txt | 2 +- examples/django/tests/conftest.py | 5 +- 12 files changed, 61 insertions(+), 64 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c1d91364c..bc35179ba 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -40,6 +40,7 @@ repos: - id: check-ast - id: check-case-conflict - id: check-docstring-first + exclude: "examples/django/proj/settings.py" - id: check-json - id: check-merge-conflict - id: check-shebang-scripts-are-executable diff --git a/examples/django/demoapp/migrations/0001_initial.py b/examples/django/demoapp/migrations/0001_initial.py index 83d71cbfb..0bc1aa42e 100644 --- a/examples/django/demoapp/migrations/0001_initial.py +++ b/examples/django/demoapp/migrations/0001_initial.py @@ -1,21 +1,20 @@ # Generated by Django 2.2.1 on 2019-05-24 21:37 -from django.db import migrations, models +from django.db import migrations +from django.db import models class Migration(migrations.Migration): - initial = True - dependencies = [ - ] + dependencies = [] operations = [ migrations.CreateModel( - name='Widget', + name="Widget", fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(max_length=140)), + ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")), + ("name", models.CharField(max_length=140)), ], ), ] diff --git a/examples/django/demoapp/tasks.py b/examples/django/demoapp/tasks.py index 866b53d24..fe681a75a 100644 --- a/examples/django/demoapp/tasks.py +++ b/examples/django/demoapp/tasks.py @@ -1,9 +1,9 @@ # Create your tasks here -from .models import Widget - from celery import shared_task +from .models import Widget + @shared_task def add(x, y): diff --git a/examples/django/manage.py b/examples/django/manage.py index 2ac73ab8d..71bd74d74 100755 --- a/examples/django/manage.py +++ b/examples/django/manage.py @@ -3,8 +3,8 @@ import os import sys -if __name__ == '__main__': - os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'proj.settings') +if __name__ == "__main__": + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "proj.settings") from django.core.management import execute_from_command_line diff --git a/examples/django/proj/__init__.py b/examples/django/proj/__init__.py index 15d7c5085..5568b6d79 100644 --- a/examples/django/proj/__init__.py +++ b/examples/django/proj/__init__.py @@ -2,4 +2,4 @@ # Django starts so that shared_task will use this app. from .celery import app as celery_app -__all__ = ('celery_app',) +__all__ = ("celery_app",) diff --git a/examples/django/proj/celery.py b/examples/django/proj/celery.py index ec3354dcd..a9c583d97 100644 --- a/examples/django/proj/celery.py +++ b/examples/django/proj/celery.py @@ -3,15 +3,15 @@ from celery import Celery # Set the default Django settings module for the 'celery' program. -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'proj.settings') +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "proj.settings") -app = Celery('proj') +app = Celery("proj") # Using a string here means the worker doesn't have to serialize # the configuration object to child processes. # - namespace='CELERY' means all celery-related configuration keys # should have a `CELERY_` prefix. -app.config_from_object('django.conf:settings', namespace='CELERY') +app.config_from_object("django.conf:settings", namespace="CELERY") # Load task modules from all registered Django apps. app.autodiscover_tasks() @@ -19,4 +19,4 @@ @app.task(bind=True, ignore_result=True) def debug_task(self): - print(f'Request: {self.request!r}') + print(f"Request: {self.request!r}") diff --git a/examples/django/proj/settings.py b/examples/django/proj/settings.py index d013991e7..d6b2580d2 100644 --- a/examples/django/proj/settings.py +++ b/examples/django/proj/settings.py @@ -7,13 +7,13 @@ # Celery settings -CELERY_BROKER_URL = 'amqp://guest:guest@localhost' +CELERY_BROKER_URL = "amqp://guest:guest@localhost" #: Only add pickle to this list if your broker is secured #: from unwanted access (see userguide/security.html) -CELERY_ACCEPT_CONTENT = ['json'] -CELERY_RESULT_BACKEND = 'db+sqlite:///results.sqlite' -CELERY_TASK_SERIALIZER = 'json' +CELERY_ACCEPT_CONTENT = ["json"] +CELERY_RESULT_BACKEND = "db+sqlite:///results.sqlite" +CELERY_TASK_SERIALIZER = "json" """ @@ -37,7 +37,7 @@ # See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'l!t+dmzf97rt9s*yrsux1py_1@odvz1szr&6&m!f@-nxq6k%%p' +SECRET_KEY = "l!t+dmzf97rt9s*yrsux1py_1@odvz1szr&6&m!f@-nxq6k%%p" # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True @@ -48,53 +48,53 @@ # Application definition INSTALLED_APPS = [ - 'django.contrib.admin', - 'django.contrib.auth', - 'django.contrib.contenttypes', - 'django.contrib.sessions', - 'django.contrib.messages', - 'django.contrib.staticfiles', - 'demoapp', + "django.contrib.admin", + "django.contrib.auth", + "django.contrib.contenttypes", + "django.contrib.sessions", + "django.contrib.messages", + "django.contrib.staticfiles", + "demoapp", ] MIDDLEWARE = [ - 'django.middleware.security.SecurityMiddleware', - 'django.contrib.sessions.middleware.SessionMiddleware', - 'django.middleware.common.CommonMiddleware', - 'django.middleware.csrf.CsrfViewMiddleware', - 'django.contrib.auth.middleware.AuthenticationMiddleware', - 'django.contrib.messages.middleware.MessageMiddleware', - 'django.middleware.clickjacking.XFrameOptionsMiddleware', + "django.middleware.security.SecurityMiddleware", + "django.contrib.sessions.middleware.SessionMiddleware", + "django.middleware.common.CommonMiddleware", + "django.middleware.csrf.CsrfViewMiddleware", + "django.contrib.auth.middleware.AuthenticationMiddleware", + "django.contrib.messages.middleware.MessageMiddleware", + "django.middleware.clickjacking.XFrameOptionsMiddleware", ] -ROOT_URLCONF = 'proj.urls' +ROOT_URLCONF = "proj.urls" TEMPLATES = [ { - 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [], - 'APP_DIRS': True, - 'OPTIONS': { - 'context_processors': [ - 'django.template.context_processors.debug', - 'django.template.context_processors.request', - 'django.contrib.auth.context_processors.auth', - 'django.contrib.messages.context_processors.messages', + "BACKEND": "django.template.backends.django.DjangoTemplates", + "DIRS": [], + "APP_DIRS": True, + "OPTIONS": { + "context_processors": [ + "django.template.context_processors.debug", + "django.template.context_processors.request", + "django.contrib.auth.context_processors.auth", + "django.contrib.messages.context_processors.messages", ], }, }, ] -WSGI_APPLICATION = 'proj.wsgi.application' +WSGI_APPLICATION = "proj.wsgi.application" # Database # https://docs.djangoproject.com/en/2.2/ref/settings/#databases DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + "default": { + "ENGINE": "django.db.backends.sqlite3", + "NAME": os.path.join(BASE_DIR, "db.sqlite3"), } } @@ -104,16 +104,16 @@ AUTH_PASSWORD_VALIDATORS = [ { - 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator", }, { - 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator", }, { - 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator", }, { - 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator", }, ] @@ -121,9 +121,9 @@ # Internationalization # https://docs.djangoproject.com/en/2.2/topics/i18n/ -LANGUAGE_CODE = 'en-us' +LANGUAGE_CODE = "en-us" -TIME_ZONE = 'UTC' +TIME_ZONE = "UTC" USE_I18N = True @@ -135,4 +135,4 @@ # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/2.2/howto/static-files/ -STATIC_URL = '/static/' +STATIC_URL = "/static/" diff --git a/examples/django/proj/urls.py b/examples/django/proj/urls.py index 51aca9d58..42bdf2e52 100644 --- a/examples/django/proj/urls.py +++ b/examples/django/proj/urls.py @@ -6,10 +6,8 @@ # Examples: # url(r'^$', 'proj.views.home', name='home'), # url(r'^proj/', include('proj.foo.urls')), - # Uncomment the admin/doc line below to enable admin documentation: # url(r'^admin/doc/', include('django.contrib.admindocs.urls')), - # Uncomment the next line to enable the admin: # url(r'^admin/', include(admin.site.urls)), ] diff --git a/examples/django/proj/wsgi.py b/examples/django/proj/wsgi.py index d07dbf074..d48b8110a 100644 --- a/examples/django/proj/wsgi.py +++ b/examples/django/proj/wsgi.py @@ -21,7 +21,7 @@ # setting points here. from django.core.wsgi import get_wsgi_application -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'proj.settings') +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "proj.settings") application = get_wsgi_application() diff --git a/examples/django/pytest.ini b/examples/django/pytest.ini index be5812d48..de6463eca 100644 --- a/examples/django/pytest.ini +++ b/examples/django/pytest.ini @@ -1,2 +1,2 @@ [pytest] -DJANGO_SETTINGS_MODULE = 'proj.settings' \ No newline at end of file +DJANGO_SETTINGS_MODULE = 'proj.settings' diff --git a/examples/django/requirements.txt b/examples/django/requirements.txt index 2e67d525b..c11b1014e 100644 --- a/examples/django/requirements.txt +++ b/examples/django/requirements.txt @@ -4,4 +4,4 @@ django>=2.2.1 pytest-django>=4.7.0 # pytest-celery>=1.0.0 git+https://github.com/celery/pytest-celery.git -pytest-xdist>=3.5.0 \ No newline at end of file +pytest-xdist>=3.5.0 diff --git a/examples/django/tests/conftest.py b/examples/django/tests/conftest.py index ff946b0f5..08373b667 100644 --- a/examples/django/tests/conftest.py +++ b/examples/django/tests/conftest.py @@ -2,7 +2,6 @@ import os from typing import Any -from typing import Type import celery import pytest @@ -63,10 +62,10 @@ def worker_queue(cls) -> str: @pytest.fixture -def default_worker_container_cls() -> Type[CeleryWorkerContainer]: +def default_worker_container_cls() -> type[CeleryWorkerContainer]: return DjangoWorkerContainer @pytest.fixture(scope="session") -def default_worker_container_session_cls() -> Type[CeleryWorkerContainer]: +def default_worker_container_session_cls() -> type[CeleryWorkerContainer]: return DjangoWorkerContainer