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 rest_framework.routers import DefaultRouter, SimpleRouter
|
||||
|
||||
|
||||
if settings.DEBUG:
|
||||
router = DefaultRouter()
|
||||
else:
|
||||
router = SimpleRouter()
|
||||
|
||||
# router.register("users", UserViewSet)
|
||||
|
||||
|
||||
app_name = "api"
|
||||
urlpatterns = router.urls
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ django_application = get_asgi_application()
|
|||
# application = HelloWorldApplication(application)
|
||||
|
||||
# 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
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -232,7 +232,9 @@ MANAGERS = ADMINS
|
|||
# https://docs.djangoproject.com/en/dev/ref/settings/#logging
|
||||
# See https://docs.djangoproject.com/en/dev/topics/logging for
|
||||
# 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":
|
||||
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,
|
||||
]
|
||||
LOGGING = {
|
||||
'version': 1,
|
||||
'disable_existing_loggers': False,
|
||||
'formatters': {
|
||||
'colored': {
|
||||
'()': structlog.stdlib.ProcessorFormatter,
|
||||
'processor': structlog.dev.ConsoleRenderer(colors=True),
|
||||
'foreign_pre_chain': pre_chain,
|
||||
"version": 1,
|
||||
"disable_existing_loggers": False,
|
||||
"formatters": {
|
||||
"colored": {
|
||||
"()": structlog.stdlib.ProcessorFormatter,
|
||||
"processor": structlog.dev.ConsoleRenderer(colors=True),
|
||||
"foreign_pre_chain": pre_chain,
|
||||
},
|
||||
},
|
||||
'handlers': {
|
||||
'default': {
|
||||
'class': 'logging.StreamHandler',
|
||||
'formatter': 'colored',
|
||||
"handlers": {
|
||||
"default": {
|
||||
"class": "logging.StreamHandler",
|
||||
"formatter": "colored",
|
||||
},
|
||||
},
|
||||
'loggers': {
|
||||
'': {
|
||||
'handlers': ['default'],
|
||||
'level': 'INFO',
|
||||
'propagate': True,
|
||||
"loggers": {
|
||||
"": {
|
||||
"handlers": ["default"],
|
||||
"level": "INFO",
|
||||
"propagate": True,
|
||||
},
|
||||
'vbv_lernwelt': {
|
||||
'handlers': ['default'],
|
||||
'level': 'DEBUG',
|
||||
'propagate': False,
|
||||
"vbv_lernwelt": {
|
||||
"handlers": ["default"],
|
||||
"level": "DEBUG",
|
||||
"propagate": False,
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
structlog.configure(
|
||||
|
|
@ -287,22 +289,23 @@ if VBV_DJANGO_LOGGING_CONF == "VBV_DJANGO_LOGGING_CONF_CONSOLE_COLOR":
|
|||
)
|
||||
else:
|
||||
LOGGING = {
|
||||
'version': 1,
|
||||
'disable_existing_loggers': True,
|
||||
'formatters': {
|
||||
'json': {
|
||||
'()': 'pythonjsonlogger.jsonlogger.JsonFormatter',
|
||||
'format': '%(asctime)s %(msecs)03d %(process)d %(thread)d %(levelname)s %(name)s %(filename)s %(lineno)d %(funcName)s %(message)s',
|
||||
'datefmt': '%Y-%m-%dT%H:%M:%S',
|
||||
"version": 1,
|
||||
"disable_existing_loggers": True,
|
||||
"formatters": {
|
||||
"json": {
|
||||
"()": "pythonjsonlogger.jsonlogger.JsonFormatter",
|
||||
# noqa I004
|
||||
"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': {
|
||||
'file': {
|
||||
'class': 'concurrent_log_handler.ConcurrentRotatingFileHandler',
|
||||
'filename': f'{SERVER_ROOT_DIR}/myservice.log',
|
||||
'maxBytes': 1024 * 1024 * 100,
|
||||
'backupCount': 50,
|
||||
'formatter': 'json',
|
||||
"handlers": {
|
||||
"file": {
|
||||
"class": "concurrent_log_handler.ConcurrentRotatingFileHandler",
|
||||
"filename": f"{SERVER_ROOT_DIR}/myservice.log",
|
||||
"maxBytes": 1024 * 1024 * 100,
|
||||
"backupCount": 50,
|
||||
"formatter": "json",
|
||||
},
|
||||
"console": {
|
||||
"level": "DEBUG",
|
||||
|
|
@ -310,23 +313,27 @@ else:
|
|||
"formatter": "json",
|
||||
},
|
||||
},
|
||||
'loggers': {
|
||||
'': {
|
||||
'handlers': ['console', 'file'],
|
||||
'level': 'INFO',
|
||||
"loggers": {
|
||||
"": {
|
||||
"handlers": ["console", "file"],
|
||||
"level": "INFO",
|
||||
},
|
||||
'django': {
|
||||
'handlers': ['console', 'file'],
|
||||
'level': 'WARNING',
|
||||
'propagate': False,
|
||||
"django": {
|
||||
"handlers": ["console", "file"],
|
||||
"level": "WARNING",
|
||||
"propagate": False,
|
||||
},
|
||||
'vbc_lernwelt': {
|
||||
'handlers': ['console', 'file'],
|
||||
'level': 'DEBUG',
|
||||
'propagate': False,
|
||||
"vbc_lernwelt": {
|
||||
"handlers": ["console", "file"],
|
||||
"level": "DEBUG",
|
||||
"propagate": False,
|
||||
},
|
||||
"sentry_sdk": {"level": "ERROR", "handlers": ["console"], "propagate": False},
|
||||
}
|
||||
"sentry_sdk": {
|
||||
"level": "ERROR",
|
||||
"handlers": ["console"],
|
||||
"propagate": False,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
structlog.configure(
|
||||
|
|
@ -381,22 +388,30 @@ SECRET_KEY = env(
|
|||
default="J9FiYN31FuY7lHrmx9Mpai3GGpTVCxakEclOfCLretDe7bTf2DtTsgazJ0aIMtbq",
|
||||
)
|
||||
# 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 = {
|
||||
'default': {
|
||||
'BACKEND': env("VBV_DJANGO_CACHE_BACKEND", default='django.core.cache.backends.db.DatabaseCache'),
|
||||
'LOCATION': env("VBV_DJANGO_CACHE_LOCATION", default='django_cache_table'),
|
||||
"default": {
|
||||
"BACKEND": env(
|
||||
"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 = {
|
||||
'default': {
|
||||
'BACKEND': env("VBV_DJANGO_CACHE_BACKEND", default='django.core.cache.backends.db.DatabaseCache'),
|
||||
'LOCATION': env("VBV_DJANGO_CACHE_LOCATION", default='django_cache_table'),
|
||||
"default": {
|
||||
"BACKEND": env(
|
||||
"VBV_DJANGO_CACHE_BACKEND",
|
||||
default="django.core.cache.backends.db.DatabaseCache",
|
||||
),
|
||||
"LOCATION": env("VBV_DJANGO_CACHE_LOCATION", default="django_cache_table"),
|
||||
"OPTIONS": {
|
||||
"CLIENT_CLASS": "django_redis.client.DefaultClient",
|
||||
# Mimicing memcache behavior.
|
||||
|
|
@ -517,6 +532,7 @@ if DJANGO_DEV_MODE == "production":
|
|||
event_level=logging.ERROR, # Send errors as events
|
||||
)
|
||||
integrations = [sentry_logging, DjangoIntegration(), RedisIntegration()]
|
||||
# pylint: disable=abstract-class-instantiated
|
||||
sentry_sdk.init(
|
||||
dsn=SENTRY_DSN,
|
||||
integrations=integrations,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
"""
|
||||
With these settings, tests run faster.
|
||||
"""
|
||||
# pylint: disable=unused-wildcard-import,wildcard-import,wrong-import-position
|
||||
|
||||
from .base import * # noqa
|
||||
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
|
||||
|
||||
urlpatterns = [
|
||||
path("", 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"),
|
||||
path(
|
||||
"",
|
||||
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' %}
|
||||
path(settings.ADMIN_URL, admin.site.urls),
|
||||
# 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)
|
||||
if settings.DEBUG:
|
||||
# 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):
|
||||
try:
|
||||
# pylint: disable=unused-import,import-outside-toplevel
|
||||
import vbv_lernwelt.core.signals # noqa F401
|
||||
except ImportError:
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -9,8 +9,6 @@ class User(AbstractUser):
|
|||
If adding fields that need to be filled at user signup,
|
||||
"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class SecurityRequestResponseLog(models.Model):
|
||||
label = models.CharField(max_length=255, blank=True, default="")
|
||||
|
|
|
|||
|
|
@ -1,3 +1 @@
|
|||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
|
|
|
|||
|
|
@ -1,3 +1 @@
|
|||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
||||
|
|
|
|||
Loading…
Reference in New Issue