tox: fix pylint

This commit is contained in:
Benjamin Dauvergne 2022-03-10 17:11:53 +01:00
parent 2ce0cf927e
commit af7e404f84
8 changed files with 142 additions and 22 deletions

View File

@ -16,6 +16,7 @@
import logging import logging
from urllib import parse as urlparse
try: try:
from functools import reduce from functools import reduce
@ -32,8 +33,7 @@ from atomicwrites import atomic_write
from django.conf import settings from django.conf import settings
from django.db.models.query import F, Q from django.db.models.query import F, Q
from django.db.transaction import atomic from django.db.transaction import atomic
from django.http import HttpResponse, StreamingHttpResponse from django.http import HttpResponse
from django.utils.six.moves.urllib import parse as urlparse
from rest_framework import status from rest_framework import status
from rest_framework.response import Response from rest_framework.response import Response
from rest_framework.views import APIView from rest_framework.views import APIView

View File

@ -15,11 +15,11 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import logging import logging
from urllib import parse as urlparse
import requests import requests
from django.conf import settings from django.conf import settings
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.utils.six.moves.urllib import parse as urlparse
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from rest_framework.authentication import BasicAuthentication from rest_framework.authentication import BasicAuthentication
from rest_framework.exceptions import AuthenticationFailed from rest_framework.exceptions import AuthenticationFailed

View File

@ -2,8 +2,6 @@ import django.core.validators
from django.conf import settings from django.conf import settings
from django.db import migrations, models from django.db import migrations, models
import petale.models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -21,7 +21,6 @@ from django.contrib.auth.models import User
from django.core.mail import send_mail from django.core.mail import send_mail
from django.core.validators import RegexValidator from django.core.validators import RegexValidator
from django.db import models from django.db import models
from django.utils import six
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from . import utils from . import utils
@ -49,7 +48,7 @@ class Partner(models.Model):
size = models.BigIntegerField(verbose_name=_('Size'), default=0, help_text=_('as bytes')) size = models.BigIntegerField(verbose_name=_('Size'), default=0, help_text=_('as bytes'))
def __str__(self): def __str__(self):
return self.name return str(self.name)
def check_limits(self, size_delta, **kwargs): def check_limits(self, size_delta, **kwargs):
new_size = self.size + size_delta new_size = self.size + size_delta
@ -84,7 +83,7 @@ class CUT(models.Model):
uuid = models.CharField(max_length=255, validators=[id_validator], unique=True) uuid = models.CharField(max_length=255, validators=[id_validator], unique=True)
def __str__(self): def __str__(self):
return self.uuid return str(self.uuid)
class Meta: class Meta:
verbose_name = _('CUT') verbose_name = _('CUT')

View File

@ -14,7 +14,7 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from django.conf.urls import include, url from django.conf.urls import url
from django.contrib import admin from django.contrib import admin
from .api_views import PetalAPIKeysView, PetalAPIView from .api_views import PetalAPIKeysView, PetalAPIView

128
pylint.rc Normal file
View File

@ -0,0 +1,128 @@
[MASTER]
profile=no
persistent=yes
cache-size=500
[MESSAGES CONTROL]
disable=
abstract-method,
arguments-differ,
assignment-from-none,
attribute-defined-outside-init,
bad-super-call,
broad-except,
consider-using-dict-comprehension,
consider-using-set-comprehension,
cyclic-import,
duplicate-code,
exec-used,
fixme,
global-variable-undefined,
import-outside-toplevel,
inconsistent-return-statements,
invalid-name,
keyword-arg-before-vararg,
missing-class-docstring,
missing-function-docstring,
missing-module-docstring,
no-else-return,
no-member,
no-self-use,
non-parent-init-called,
not-callable,
possibly-unused-variable,
protected-access,
raise-missing-from,
redefined-argument-from-local,
redefined-builtin,
redefined-outer-name,
signature-differs,
stop-iteration-return,
super-init-not-called,
superfluous-parens,
too-many-ancestors,
too-many-arguments,
too-many-branches,
too-many-instance-attributes,
too-many-lines,
too-many-locals,
too-many-nested-blocks,
too-many-return-statements,
too-many-statements,
undefined-loop-variable,
unnecessary-comprehension,
unspecified-encoding,
unsubscriptable-object,
unsupported-membership-test,
unused-argument,
use-a-generator,
c-extension-no-member,
consider-using-f-string
[REPORTS]
output-format=parseable
include-ids=yes
[BASIC]
no-docstring-rgx=__.*__|_.*
class-rgx=[A-Z_][a-zA-Z0-9_]+$
function-rgx=[a-zA_][a-zA-Z0-9_]{2,70}$
method-rgx=[a-z_][a-zA-Z0-9_]{2,70}$
const-rgx=(([A-Z_][A-Z0-9_]*)|([a-z_][a-z0-9_]*)|(__.*__)|register|urlpatterns)$
good-names=_,i,j,k,e,x,Run,,setUp,tearDown,r,p,s,v,fd
[TYPECHECK]
# Tells whether missing members accessed in mixin class should be ignored. A
# mixin class is detected if its name ends with "mixin" (case insensitive).
ignore-mixin-members=yes
# List of classes names for which member attributes should not be checked
# (useful for classes with attributes dynamically set).
ignored-classes=
# When zope mode is activated, add a predefined set of Zope acquired attributes
# to generated-members.
zope=no
# List of members which are set dynamically and missed by pylint inference
# system, and so shouldn't trigger E0201 when accessed.
generated-members=objects,DoesNotExist,id,pk,_meta,base_fields,context
# List of method names used to declare (i.e. assign) instance attributes
defining-attr-methods=__init__,__new__,setUp
[VARIABLES]
init-import=no
dummy-variables-rgx=_|dummy
good-names=_,i,j,k,e,x,Run,,setUp,tearDown,r,p,s,v,fd
[SIMILARITIES]
min-similarity-lines=6
ignore-comments=yes
ignore-docstrings=yes
[MISCELLANEOUS]
notes=FIXME,XXX,TODO
[FORMAT]
max-line-length=160
max-module-lines=2000
indent-string=' '
[DESIGN]
max-args=10
max-locals=15
max-returns=6
max-branchs=12
max-statements=50
max-parents=7
max-attributes=7
min-public-methods=0
max-public-methods=50

View File

@ -1,13 +1,4 @@
#!/bin/bash #!/bin/bash
set -e set -e
if [ -f /var/lib/jenkins/pylint.django.rc ]; then pylint -f parseable --rcfile pylint.rc "$@" | tee pylint.out; test $PIPESTATUS -eq 0
PYLINT_RC=/var/lib/jenkins/pylint.django.rc
elif [ -f pylint.django.rc ]; then
PYLINT_RC=pylint.django.rc
else
echo No pylint RC found
exit 0
fi
pylint -f parseable --rcfile ${PYLINT_RC} "$@" > pylint.out || /bin/true

10
tox.ini
View File

@ -55,12 +55,16 @@ commands =
./manage.py {posargs:--help} ./manage.py {posargs:--help}
[testenv:pylint] [testenv:pylint]
usedevelop = true
basepython = python3 basepython = python3
setenv =
DJANGO_SETTINGS_MODULE=petale.settings
PETALE_SETTINGS_FILE=tests/settings.py
SETUPTOOLS_USE_DISTUTILS=stdlib
deps = deps =
Django<2.3 Django<2.3
pylint<1.8 psycopg2-binary
pylint-django<0.8.1 pylint
pylint-django
commands = commands =
/bin/bash -c "./pylint.sh petale/" /bin/bash -c "./pylint.sh petale/"