зеркало из https://github.com/nextcloud/appstore.git
replaced `pycodestyle` with `flake8`
Signed-off-by: bigcat88 <bigcat88@icloud.com>
This commit is contained in:
Родитель
d28c976a15
Коммит
19e60b66ad
|
@ -53,6 +53,18 @@ repos:
|
|||
args:
|
||||
- --ignore-missing-imports
|
||||
|
||||
- repo: https://github.com/PyCQA/flake8
|
||||
rev: 6.0.0
|
||||
hooks:
|
||||
- id: flake8
|
||||
files: nextcloudappstore
|
||||
exclude: nextcloudappstore/core/migrations
|
||||
types: [file, python]
|
||||
args:
|
||||
- --max-line-length=120
|
||||
- --ignore=E203,W503
|
||||
- --per-file-ignores=__init__.py:F401,F403
|
||||
|
||||
- repo: https://github.com/PyCQA/bandit
|
||||
rev: 1.7.5
|
||||
hooks:
|
||||
|
|
7
Makefile
7
Makefile
|
@ -1,7 +1,6 @@
|
|||
poetry=poetry
|
||||
poetry_run=$(poetry) run
|
||||
python=$(poetry_run) python
|
||||
pycodestyle=$(poetry_run) pycodestyle
|
||||
pyresttest=$(poetry_run) pyresttest
|
||||
coverage=$(poetry_run) coverage
|
||||
manage-script=$(CURDIR)/manage.py
|
||||
|
@ -10,12 +9,8 @@ db=sqlite
|
|||
npm=npm
|
||||
prod_version=12.0.0
|
||||
|
||||
.PHONY: lint
|
||||
lint:
|
||||
$(pycodestyle) $(CURDIR)/nextcloudappstore --exclude=migrations,development.py --max-line-length=80
|
||||
|
||||
.PHONY: test
|
||||
test: lint
|
||||
test:
|
||||
$(npm) test
|
||||
$(coverage) run --source=nextcloudappstore $(manage-script) test --settings nextcloudappstore.settings.development -v 2
|
||||
$(coverage) report --fail-under 90
|
||||
|
|
|
@ -60,7 +60,7 @@ class AppReleaseDownloader:
|
|||
req = session.get(url, stream=True, timeout=timeout)
|
||||
req.raise_for_status()
|
||||
self._stream_to_file(file, max_size, req)
|
||||
except requests.exceptions.RequestException as e:
|
||||
except requests.exceptions.RequestException:
|
||||
"""
|
||||
We previously passed the whole error message to the client which
|
||||
is unwanted in case of a malicious client - the error message could
|
||||
|
|
|
@ -28,7 +28,7 @@ class AppReleaseAdmin(admin.ModelAdmin):
|
|||
|
||||
|
||||
@admin.register(AppRelease)
|
||||
class AppReleaseAdmin(TranslatableAdmin):
|
||||
class AppReleaseAdmin(TranslatableAdmin): # noqa
|
||||
inlines = (DatabaseDependencyInline, PhpExtensionDependencyInline)
|
||||
list_display = ('app', 'version', 'is_nightly', 'last_modified')
|
||||
list_filter = ('app__id', 'is_nightly', 'last_modified')
|
||||
|
|
|
@ -83,7 +83,7 @@ def distinct(iterable: Iterable[T],
|
|||
a custom distinctness criteria
|
||||
:return: a distinct iterator of elements from an iterable
|
||||
"""
|
||||
occurred_values = set() # type: Set[U]
|
||||
occurred_values: Set[U] = set()
|
||||
for element in iterable:
|
||||
value = criteria(element)
|
||||
if value not in occurred_values:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from django.conf import settings
|
||||
from django.core.management import BaseCommand, CommandError
|
||||
from django.utils.translation import activate, ugettext
|
||||
from django.utils.translation import ugettext
|
||||
from parler.models import TranslatableModel
|
||||
from parler.utils.context import switch_language
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import time
|
||||
import unittest
|
||||
from io import StringIO
|
||||
|
||||
|
|
|
@ -28,9 +28,9 @@ class AppManager(TranslatableManager):
|
|||
def search(self, terms, lang):
|
||||
queryset = self.get_queryset().active_translations(lang).language(
|
||||
lang).distinct()
|
||||
predicates = map(lambda t: (Q(translations__name__icontains=t) |
|
||||
Q(translations__summary__icontains=t) |
|
||||
Q(translations__description__icontains=t)),
|
||||
predicates = map(lambda t: (Q(translations__name__icontains=t)
|
||||
| Q(translations__summary__icontains=t)
|
||||
| Q(translations__description__icontains=t)),
|
||||
terms)
|
||||
query = reduce(lambda x, y: x & y, predicates, Q())
|
||||
return queryset.filter(query)
|
||||
|
@ -475,8 +475,8 @@ class Category(TranslatableModel):
|
|||
last_modified = DateTimeField(auto_now=True, editable=False, db_index=True,
|
||||
verbose_name=_('Updated at'))
|
||||
translations = TranslatedFields(
|
||||
name=CharField(max_length=256, help_text=_(
|
||||
'Category name which will be presented to the user'),
|
||||
name=CharField(max_length=256,
|
||||
help_text=_('Category name which will be presented to the user'),
|
||||
verbose_name=_('Name')),
|
||||
description=TextField(verbose_name=_('Description'),
|
||||
help_text=_('Will be rendered as Markdown'))
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from django.test import tag
|
||||
|
||||
from nextcloudappstore.core.tests.e2e import TEST_PASSWORD, TEST_USER
|
||||
from nextcloudappstore.core.tests.e2e import TEST_PASSWORD # , TEST_USER
|
||||
from nextcloudappstore.core.tests.e2e.base import BaseStoreTest
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
import os
|
||||
|
||||
from django.test import tag
|
||||
|
||||
from nextcloudappstore.core.tests.e2e.base import BaseStoreTest
|
||||
|
|
|
@ -48,10 +48,10 @@ class GitHubTest(TestCase):
|
|||
|
||||
self.assertEquals(16, NextcloudRelease.objects.count())
|
||||
self.assertEquals(False, self.get_rel('10.0.0').is_supported)
|
||||
self.assertEquals(True, self.get_rel('10.0.0').has_release)
|
||||
self.assertEquals(True, self.get_rel('10.0.0').has_release)
|
||||
self.assertEquals(False, self.get_rel('10.0.0').is_current)
|
||||
self.assertEquals(False, self.get_rel('10.0.1').is_supported)
|
||||
self.assertEquals(True, self.get_rel('10.0.1').has_release)
|
||||
self.assertEquals(True, self.get_rel('10.0.1').has_release)
|
||||
self.assertEquals(False, self.get_rel('10.0.1').is_current)
|
||||
self.assertEquals(True, self.get_rel('11.0.0').is_supported)
|
||||
self.assertEquals(True, self.get_rel('11.0.0').has_release)
|
||||
|
|
|
@ -196,13 +196,11 @@ class CategoryAppListView(ListView):
|
|||
lang = get_language_info(get_language())['code']
|
||||
category_id = self.kwargs['id']
|
||||
queryset = App.objects.search(self.search_terms, lang).order_by(
|
||||
*sort_columns).filter(Q(releases__gt=0) | (Q(is_integration=True) &
|
||||
Q(approved=True)))
|
||||
*sort_columns).filter(Q(releases__gt=0) | (Q(is_integration=True) & Q(approved=True)))
|
||||
if maintainer:
|
||||
try:
|
||||
user = User.objects.get_by_natural_key(maintainer)
|
||||
queryset = queryset.filter(Q(owner=user) |
|
||||
Q(co_maintainers=user))
|
||||
queryset = queryset.filter(Q(owner=user) | Q(co_maintainers=user))
|
||||
except ObjectDoesNotExist:
|
||||
return queryset.none()
|
||||
if category_id:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# recommended default settings to inherit in a production environment
|
||||
from nextcloudappstore.settings.base import *
|
||||
from nextcloudappstore.settings.base import * # noqa
|
||||
|
||||
# DEBUG must be false to not leak sensitive content
|
||||
DEBUG = False
|
||||
|
@ -13,6 +13,6 @@ ACCOUNT_DEFAULT_HTTP_PROTOCOL = 'https'
|
|||
CSP_IMG_SRC = ('https:',)
|
||||
|
||||
LOG_LEVEL = 'ERROR'
|
||||
LOGGING['handlers']['file']['filename'] = LOG_FILE
|
||||
LOGGING['handlers']['file']['level'] = LOG_LEVEL
|
||||
LOGGING['loggers']['django']['level'] = LOG_LEVEL
|
||||
LOGGING['handlers']['file']['filename'] = LOG_FILE # noqa
|
||||
LOGGING['handlers']['file']['level'] = LOG_LEVEL # noqa
|
||||
LOGGING['loggers']['django']['level'] = LOG_LEVEL # noqa
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
from django.contrib import admin
|
||||
from django.contrib import admin # noqa
|
||||
|
||||
# Register your models here.
|
||||
|
|
|
@ -12,5 +12,5 @@ class UserConfig(AppConfig):
|
|||
def ready(self):
|
||||
# during tests ready can be called more than once.
|
||||
if not self._ready:
|
||||
from . import signals
|
||||
from . import signals # noqa
|
||||
self._ready = True
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
from django.db import models
|
||||
from django.db import models # noqa
|
||||
|
||||
# Create your models here.
|
||||
|
|
|
@ -40,10 +40,10 @@ def password_changed_signal(sender, instance, **kwargs):
|
|||
# was changed due to a new default hashing algorithm
|
||||
update_token(user.username)
|
||||
send_mail(
|
||||
mail_subect,
|
||||
mail_message,
|
||||
settings.DEFAULT_FROM_EMAIL,
|
||||
[user.email],
|
||||
False)
|
||||
mail_subect,
|
||||
mail_message,
|
||||
settings.DEFAULT_FROM_EMAIL,
|
||||
[user.email],
|
||||
False)
|
||||
except User.DoesNotExist:
|
||||
pass
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
from django.test import TestCase
|
||||
from django.test import TestCase # noqa
|
||||
|
||||
# Create your tests here.
|
||||
|
|
Загрузка…
Ссылка в новой задаче