Code formatting
This commit is contained in:
parent
425273c5a3
commit
045391fc59
14
.pylintrc
14
.pylintrc
|
|
@ -1,14 +0,0 @@
|
||||||
[MASTER]
|
|
||||||
load-plugins=pylint_django
|
|
||||||
django-settings-module=config.settings.base
|
|
||||||
[FORMAT]
|
|
||||||
max-line-length=120
|
|
||||||
|
|
||||||
[MESSAGES CONTROL]
|
|
||||||
disable=missing-docstring,invalid-name
|
|
||||||
|
|
||||||
[DESIGN]
|
|
||||||
max-parents=13
|
|
||||||
|
|
||||||
[TYPECHECK]
|
|
||||||
generated-members=REQUEST,acl_users,aq_parent,"[a-zA-Z]+_set{1,2}",save,delete
|
|
||||||
|
|
@ -0,0 +1,87 @@
|
||||||
|
[MASTER]
|
||||||
|
load-plugins=pylint_django
|
||||||
|
django-settings-module=config.settings.base
|
||||||
|
[FORMAT]
|
||||||
|
max-line-length=120
|
||||||
|
|
||||||
|
[MESSAGES CONTROL]
|
||||||
|
disable=missing-docstring,invalid-name
|
||||||
|
|
||||||
|
[DESIGN]
|
||||||
|
max-parents=13
|
||||||
|
|
||||||
|
[TYPECHECK]
|
||||||
|
generated-members=REQUEST,acl_users,aq_parent,"[a-zA-Z]+_set{1,2}",save,delete
|
||||||
|
|
||||||
|
# Disable the message, report, category or checker with the given id(s). You
|
||||||
|
# can either give multiple identifiers separated by comma (,) or put this
|
||||||
|
# option multiple times (only on the command line, not in the configuration
|
||||||
|
# file where it should appear only once). You can also use "--disable=all" to
|
||||||
|
# disable everything first and then reenable specific checks. For example, if
|
||||||
|
# you want to run only the similarities checker, you can use "--disable=all
|
||||||
|
# --enable=similarities". If you want to run only the classes checker, but have
|
||||||
|
# no Warning level messages displayed, use "--disable=all --enable=classes
|
||||||
|
# --disable=W".
|
||||||
|
disable=
|
||||||
|
# C0114: Missing module docstring
|
||||||
|
missing-module-docstring,
|
||||||
|
# C0116: Missing function or method docstring
|
||||||
|
missing-function-docstring,
|
||||||
|
# C0115: Missing class docstring
|
||||||
|
missing-class-docstring,
|
||||||
|
# R0201: Method could be a function
|
||||||
|
no-self-use,
|
||||||
|
# C0115: Missing class docstring
|
||||||
|
missing-class-docstring,
|
||||||
|
# C0103: Method name "test_exportHelper_returnsInvoicesOnlyOnce" doesn't conform to snake_case naming style
|
||||||
|
invalid-name,
|
||||||
|
# C0305: Trailing newlines
|
||||||
|
trailing-newlines,
|
||||||
|
# C0301: Line too long (114/100)
|
||||||
|
line-too-long,
|
||||||
|
# R0904: Too many public methods (32/20)
|
||||||
|
too-many-public-methods,
|
||||||
|
# R0903: Too few public methods (0/2)
|
||||||
|
too-few-public-methods,
|
||||||
|
# E1101: Class 'SizeChoice' has no 'objects' member
|
||||||
|
no-member,
|
||||||
|
# W0613: Unused argument 'schema_editor'
|
||||||
|
unused-argument,
|
||||||
|
# C0304: Final newline missing
|
||||||
|
missing-final-newline,
|
||||||
|
# C0303: Trailing whitespace
|
||||||
|
trailing-whitespace,
|
||||||
|
# W0511:
|
||||||
|
fixme,
|
||||||
|
# R0902: Too many instance attributes
|
||||||
|
too-many-instance-attributes,
|
||||||
|
# R0913: Too many arguments
|
||||||
|
too-many-arguments,
|
||||||
|
# R1725: Consider using Python 3 style super() without arguments
|
||||||
|
super-with-arguments,
|
||||||
|
# R0901: Too many ancestors
|
||||||
|
too-many-ancestors,
|
||||||
|
# Too many boolean expressions in if statement
|
||||||
|
too-many-boolean-expressions,
|
||||||
|
# W0212: Access to a protected member _meta of a client class
|
||||||
|
protected-access,
|
||||||
|
# W0201: Attribute defined outside __init__
|
||||||
|
attribute-defined-outside-init,
|
||||||
|
# R1721: Unnecessary use of a comprehension
|
||||||
|
unnecessary-comprehension,
|
||||||
|
# R1705: Unnecessary "else" after "return"
|
||||||
|
no-else-return,
|
||||||
|
# R1720: Unnecessary "elif" after "raise"
|
||||||
|
no-else-raise,
|
||||||
|
# R0914: Too many local variables
|
||||||
|
too-many-locals,
|
||||||
|
# R1702: Too many nested blocks
|
||||||
|
too-many-nested-blocks,
|
||||||
|
# R0911: Too many return statements
|
||||||
|
too-many-return-statements,
|
||||||
|
# R1701: Consider merging these isinstance calls
|
||||||
|
consider-merging-isinstance,
|
||||||
|
# R0915: Too many statements
|
||||||
|
too-many-statements,
|
||||||
|
duplicate-code,
|
||||||
|
cyclic-impor
|
||||||
|
|
@ -1,14 +1,11 @@
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from rest_framework.routers import DefaultRouter, SimpleRouter
|
from rest_framework.routers import DefaultRouter, SimpleRouter
|
||||||
|
|
||||||
|
|
||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
router = DefaultRouter()
|
router = DefaultRouter()
|
||||||
else:
|
else:
|
||||||
router = SimpleRouter()
|
router = SimpleRouter()
|
||||||
|
|
||||||
# router.register("users", UserViewSet)
|
|
||||||
|
|
||||||
|
|
||||||
app_name = "api"
|
app_name = "api"
|
||||||
urlpatterns = router.urls
|
urlpatterns = router.urls
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ django_application = get_asgi_application()
|
||||||
# application = HelloWorldApplication(application)
|
# application = HelloWorldApplication(application)
|
||||||
|
|
||||||
# Import websocket application here, so apps from django_application are loaded first
|
# Import websocket application here, so apps from django_application are loaded first
|
||||||
|
# pylint: disable=wrong-import-position
|
||||||
from config.websocket import websocket_application # noqa isort:skip
|
from config.websocket import websocket_application # noqa isort:skip
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -232,7 +232,9 @@ MANAGERS = ADMINS
|
||||||
# https://docs.djangoproject.com/en/dev/ref/settings/#logging
|
# https://docs.djangoproject.com/en/dev/ref/settings/#logging
|
||||||
# See https://docs.djangoproject.com/en/dev/topics/logging for
|
# See https://docs.djangoproject.com/en/dev/topics/logging for
|
||||||
# more details on how to customize your logging configuration.
|
# more details on how to customize your logging configuration.
|
||||||
VBV_DJANGO_LOGGING_CONF = env("VBV_DJANGO_LOGGING_CONF", default="VBV_DJANGO_LOGGING_CONF_JSON_FILE")
|
VBV_DJANGO_LOGGING_CONF = env(
|
||||||
|
"VBV_DJANGO_LOGGING_CONF", default="VBV_DJANGO_LOGGING_CONF_JSON_FILE"
|
||||||
|
)
|
||||||
|
|
||||||
if VBV_DJANGO_LOGGING_CONF == "VBV_DJANGO_LOGGING_CONF_CONSOLE_COLOR":
|
if VBV_DJANGO_LOGGING_CONF == "VBV_DJANGO_LOGGING_CONF_CONSOLE_COLOR":
|
||||||
timestamper = structlog.processors.TimeStamper(fmt="%Y-%m-%d %H:%M:%S")
|
timestamper = structlog.processors.TimeStamper(fmt="%Y-%m-%d %H:%M:%S")
|
||||||
|
|
@ -241,33 +243,33 @@ if VBV_DJANGO_LOGGING_CONF == "VBV_DJANGO_LOGGING_CONF_CONSOLE_COLOR":
|
||||||
timestamper,
|
timestamper,
|
||||||
]
|
]
|
||||||
LOGGING = {
|
LOGGING = {
|
||||||
'version': 1,
|
"version": 1,
|
||||||
'disable_existing_loggers': False,
|
"disable_existing_loggers": False,
|
||||||
'formatters': {
|
"formatters": {
|
||||||
'colored': {
|
"colored": {
|
||||||
'()': structlog.stdlib.ProcessorFormatter,
|
"()": structlog.stdlib.ProcessorFormatter,
|
||||||
'processor': structlog.dev.ConsoleRenderer(colors=True),
|
"processor": structlog.dev.ConsoleRenderer(colors=True),
|
||||||
'foreign_pre_chain': pre_chain,
|
"foreign_pre_chain": pre_chain,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'handlers': {
|
"handlers": {
|
||||||
'default': {
|
"default": {
|
||||||
'class': 'logging.StreamHandler',
|
"class": "logging.StreamHandler",
|
||||||
'formatter': 'colored',
|
"formatter": "colored",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'loggers': {
|
"loggers": {
|
||||||
'': {
|
"": {
|
||||||
'handlers': ['default'],
|
"handlers": ["default"],
|
||||||
'level': 'INFO',
|
"level": "INFO",
|
||||||
'propagate': True,
|
"propagate": True,
|
||||||
},
|
},
|
||||||
'vbv_lernwelt': {
|
"vbv_lernwelt": {
|
||||||
'handlers': ['default'],
|
"handlers": ["default"],
|
||||||
'level': 'DEBUG',
|
"level": "DEBUG",
|
||||||
'propagate': False,
|
"propagate": False,
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
structlog.configure(
|
structlog.configure(
|
||||||
|
|
@ -287,22 +289,23 @@ if VBV_DJANGO_LOGGING_CONF == "VBV_DJANGO_LOGGING_CONF_CONSOLE_COLOR":
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
LOGGING = {
|
LOGGING = {
|
||||||
'version': 1,
|
"version": 1,
|
||||||
'disable_existing_loggers': True,
|
"disable_existing_loggers": True,
|
||||||
'formatters': {
|
"formatters": {
|
||||||
'json': {
|
"json": {
|
||||||
'()': 'pythonjsonlogger.jsonlogger.JsonFormatter',
|
"()": "pythonjsonlogger.jsonlogger.JsonFormatter",
|
||||||
'format': '%(asctime)s %(msecs)03d %(process)d %(thread)d %(levelname)s %(name)s %(filename)s %(lineno)d %(funcName)s %(message)s',
|
# noqa I004
|
||||||
'datefmt': '%Y-%m-%dT%H:%M:%S',
|
"format": "%(asctime)s %(msecs)03d %(process)d %(thread)d %(levelname)s %(name)s %(filename)s %(lineno)d %(funcName)s %(message)s", # noqa I004
|
||||||
|
"datefmt": "%Y-%m-%dT%H:%M:%S",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'handlers': {
|
"handlers": {
|
||||||
'file': {
|
"file": {
|
||||||
'class': 'concurrent_log_handler.ConcurrentRotatingFileHandler',
|
"class": "concurrent_log_handler.ConcurrentRotatingFileHandler",
|
||||||
'filename': f'{SERVER_ROOT_DIR}/myservice.log',
|
"filename": f"{SERVER_ROOT_DIR}/myservice.log",
|
||||||
'maxBytes': 1024 * 1024 * 100,
|
"maxBytes": 1024 * 1024 * 100,
|
||||||
'backupCount': 50,
|
"backupCount": 50,
|
||||||
'formatter': 'json',
|
"formatter": "json",
|
||||||
},
|
},
|
||||||
"console": {
|
"console": {
|
||||||
"level": "DEBUG",
|
"level": "DEBUG",
|
||||||
|
|
@ -310,23 +313,27 @@ else:
|
||||||
"formatter": "json",
|
"formatter": "json",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'loggers': {
|
"loggers": {
|
||||||
'': {
|
"": {
|
||||||
'handlers': ['console', 'file'],
|
"handlers": ["console", "file"],
|
||||||
'level': 'INFO',
|
"level": "INFO",
|
||||||
},
|
},
|
||||||
'django': {
|
"django": {
|
||||||
'handlers': ['console', 'file'],
|
"handlers": ["console", "file"],
|
||||||
'level': 'WARNING',
|
"level": "WARNING",
|
||||||
'propagate': False,
|
"propagate": False,
|
||||||
},
|
},
|
||||||
'vbc_lernwelt': {
|
"vbc_lernwelt": {
|
||||||
'handlers': ['console', 'file'],
|
"handlers": ["console", "file"],
|
||||||
'level': 'DEBUG',
|
"level": "DEBUG",
|
||||||
'propagate': False,
|
"propagate": False,
|
||||||
},
|
},
|
||||||
"sentry_sdk": {"level": "ERROR", "handlers": ["console"], "propagate": False},
|
"sentry_sdk": {
|
||||||
}
|
"level": "ERROR",
|
||||||
|
"handlers": ["console"],
|
||||||
|
"propagate": False,
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
structlog.configure(
|
structlog.configure(
|
||||||
|
|
@ -381,22 +388,30 @@ SECRET_KEY = env(
|
||||||
default="J9FiYN31FuY7lHrmx9Mpai3GGpTVCxakEclOfCLretDe7bTf2DtTsgazJ0aIMtbq",
|
default="J9FiYN31FuY7lHrmx9Mpai3GGpTVCxakEclOfCLretDe7bTf2DtTsgazJ0aIMtbq",
|
||||||
)
|
)
|
||||||
# https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts
|
# https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts
|
||||||
ALLOWED_HOSTS = env.list("VBV_DJANGO_ALLOWED_HOSTS", default=["localhost", "0.0.0.0", "127.0.0.1"])
|
ALLOWED_HOSTS = env.list(
|
||||||
|
"VBV_DJANGO_ALLOWED_HOSTS", default=["localhost", "0.0.0.0", "127.0.0.1"]
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# CACHES
|
# CACHES
|
||||||
CACHES = {
|
CACHES = {
|
||||||
'default': {
|
"default": {
|
||||||
'BACKEND': env("VBV_DJANGO_CACHE_BACKEND", default='django.core.cache.backends.db.DatabaseCache'),
|
"BACKEND": env(
|
||||||
'LOCATION': env("VBV_DJANGO_CACHE_LOCATION", default='django_cache_table'),
|
"VBV_DJANGO_CACHE_BACKEND",
|
||||||
|
default="django.core.cache.backends.db.DatabaseCache",
|
||||||
|
),
|
||||||
|
"LOCATION": env("VBV_DJANGO_CACHE_LOCATION", default="django_cache_table"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if 'django_redis.cache.RedisCache' in env("VBV_DJANGO_CACHE_BACKEND", default=''):
|
if "django_redis.cache.RedisCache" in env("VBV_DJANGO_CACHE_BACKEND", default=""):
|
||||||
CACHES = {
|
CACHES = {
|
||||||
'default': {
|
"default": {
|
||||||
'BACKEND': env("VBV_DJANGO_CACHE_BACKEND", default='django.core.cache.backends.db.DatabaseCache'),
|
"BACKEND": env(
|
||||||
'LOCATION': env("VBV_DJANGO_CACHE_LOCATION", default='django_cache_table'),
|
"VBV_DJANGO_CACHE_BACKEND",
|
||||||
|
default="django.core.cache.backends.db.DatabaseCache",
|
||||||
|
),
|
||||||
|
"LOCATION": env("VBV_DJANGO_CACHE_LOCATION", default="django_cache_table"),
|
||||||
"OPTIONS": {
|
"OPTIONS": {
|
||||||
"CLIENT_CLASS": "django_redis.client.DefaultClient",
|
"CLIENT_CLASS": "django_redis.client.DefaultClient",
|
||||||
# Mimicing memcache behavior.
|
# Mimicing memcache behavior.
|
||||||
|
|
@ -517,6 +532,7 @@ if DJANGO_DEV_MODE == "production":
|
||||||
event_level=logging.ERROR, # Send errors as events
|
event_level=logging.ERROR, # Send errors as events
|
||||||
)
|
)
|
||||||
integrations = [sentry_logging, DjangoIntegration(), RedisIntegration()]
|
integrations = [sentry_logging, DjangoIntegration(), RedisIntegration()]
|
||||||
|
# pylint: disable=abstract-class-instantiated
|
||||||
sentry_sdk.init(
|
sentry_sdk.init(
|
||||||
dsn=SENTRY_DSN,
|
dsn=SENTRY_DSN,
|
||||||
integrations=integrations,
|
integrations=integrations,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,4 @@
|
||||||
"""
|
# pylint: disable=unused-wildcard-import,wildcard-import,wrong-import-position
|
||||||
With these settings, tests run faster.
|
|
||||||
"""
|
|
||||||
|
|
||||||
from .base import * # noqa
|
from .base import * # noqa
|
||||||
from .base import env
|
from .base import env
|
||||||
|
|
|
||||||
|
|
@ -12,12 +12,25 @@ from rest_framework.authtoken.views import obtain_auth_token
|
||||||
from vbv_lernwelt.core.middleware.auth import django_view_authentication_exempt
|
from vbv_lernwelt.core.middleware.auth import django_view_authentication_exempt
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("", django_view_authentication_exempt(TemplateView.as_view(template_name="pages/home.html")), name="home"),
|
path(
|
||||||
path("about/", TemplateView.as_view(template_name="pages/about.html"), name="about"),
|
"",
|
||||||
|
django_view_authentication_exempt(
|
||||||
|
TemplateView.as_view(template_name="pages/home.html")
|
||||||
|
),
|
||||||
|
name="home",
|
||||||
|
),
|
||||||
|
path(
|
||||||
|
"about/", TemplateView.as_view(template_name="pages/about.html"), name="about"
|
||||||
|
),
|
||||||
# Django Admin, use {% url 'admin:index' %}
|
# Django Admin, use {% url 'admin:index' %}
|
||||||
path(settings.ADMIN_URL, admin.site.urls),
|
path(settings.ADMIN_URL, admin.site.urls),
|
||||||
# Your stuff: custom urls includes go here
|
# Your stuff: custom urls includes go here
|
||||||
path('login/', django_view_authentication_exempt(auth_views.LoginView.as_view(template_name='core/login.html'))),
|
path(
|
||||||
|
"login/",
|
||||||
|
django_view_authentication_exempt(
|
||||||
|
auth_views.LoginView.as_view(template_name="core/login.html")
|
||||||
|
),
|
||||||
|
),
|
||||||
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
# Static file serving when using Gunicorn + Uvicorn for local web socket development
|
# Static file serving when using Gunicorn + Uvicorn for local web socket development
|
||||||
|
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
__version__ = "0.1.0"
|
|
||||||
__version_info__ = tuple(
|
|
||||||
[
|
|
||||||
int(num) if num.isdigit() else num
|
|
||||||
for num in __version__.replace("-", ".", 1).split(".")
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
import pytest
|
|
||||||
|
|
||||||
from vbv_lernwelt.users.models import User
|
|
||||||
from vbv_lernwelt.users.tests.factories import UserFactory
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
|
||||||
def media_storage(settings, tmpdir):
|
|
||||||
settings.MEDIA_ROOT = tmpdir.strpath
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def user() -> User:
|
|
||||||
return UserFactory()
|
|
||||||
|
|
@ -7,6 +7,7 @@ class CoreConfig(AppConfig):
|
||||||
|
|
||||||
def ready(self):
|
def ready(self):
|
||||||
try:
|
try:
|
||||||
|
# pylint: disable=unused-import,import-outside-toplevel
|
||||||
import vbv_lernwelt.core.signals # noqa F401
|
import vbv_lernwelt.core.signals # noqa F401
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,6 @@ class User(AbstractUser):
|
||||||
If adding fields that need to be filled at user signup,
|
If adding fields that need to be filled at user signup,
|
||||||
"""
|
"""
|
||||||
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class SecurityRequestResponseLog(models.Model):
|
class SecurityRequestResponseLog(models.Model):
|
||||||
label = models.CharField(max_length=255, blank=True, default="")
|
label = models.CharField(max_length=255, blank=True, default="")
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1 @@
|
||||||
from django.test import TestCase
|
|
||||||
|
|
||||||
# Create your tests here.
|
# Create your tests here.
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1 @@
|
||||||
from django.shortcuts import render
|
|
||||||
|
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue