mirror of
https://gitea.mueller.network/extern/django-helpdesk.git
synced 2024-11-23 08:23:54 +01:00
Move to ruff, its faster & catches more
This commit is contained in:
parent
d09c35a881
commit
6cd5522099
17
.github/workflows/pythonpackage.yml
vendored
17
.github/workflows/pythonpackage.yml
vendored
@ -28,21 +28,10 @@ jobs:
|
||||
python -m pip install --upgrade pip
|
||||
pip install -r requirements.txt -r requirements-testing.txt -c constraints-Django${{ matrix.django-version }}.txt
|
||||
|
||||
- name: Format style check with 'autopep8'
|
||||
- name: Lint with ruff
|
||||
run: |
|
||||
pip install autopep8
|
||||
autopep8 --exit-code --global-config .flake8 helpdesk
|
||||
|
||||
- name: Lint with 'flake8'
|
||||
run: |
|
||||
pip install flake8
|
||||
# stop the build if there are Python syntax errors or undefined names
|
||||
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
|
||||
flake8 helpdesk --count --show-source --statistics --exit-zero --max-complexity=20
|
||||
|
||||
- name: Sort style check with 'isort'
|
||||
run: |
|
||||
isort --line-length=120 --src helpdesk . --check
|
||||
pip install ruff
|
||||
ruff helpdesk
|
||||
|
||||
- name: Test with pytest
|
||||
run: |
|
||||
|
@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.db import models, migrations
|
||||
from django.db import migrations
|
||||
|
||||
from helpdesk.settings import DEFAULT_USER_SETTINGS
|
||||
|
||||
|
@ -1,8 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import os
|
||||
from sys import path
|
||||
|
||||
from django.db import models, migrations
|
||||
from django.db import migrations
|
||||
from django.core import serializers
|
||||
|
||||
fixture_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '../fixtures'))
|
||||
|
@ -1,5 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from django.db import models, migrations
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from django.contrib.auth import get_user_model
|
||||
from helpdesk.models import Queue, Ticket, UserSettings
|
||||
from helpdesk.models import Queue, Ticket
|
||||
import sys
|
||||
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
from django.test import TestCase
|
||||
from django.urls import reverse
|
||||
from helpdesk.models import KBCategory, KBItem, Queue, Ticket
|
||||
from helpdesk.tests.helpers import create_ticket, get_staff_user, print_response, reload_urlconf, User
|
||||
from helpdesk.tests.helpers import get_staff_user
|
||||
|
||||
|
||||
class KBTests(TestCase):
|
||||
|
@ -6,7 +6,7 @@ from django.test.utils import override_settings
|
||||
from django.urls import reverse
|
||||
from helpdesk import settings as helpdesk_settings
|
||||
from helpdesk.models import Queue
|
||||
from helpdesk.tests.helpers import create_ticket, get_staff_user, print_response, reload_urlconf, User
|
||||
from helpdesk.tests.helpers import create_ticket, get_staff_user, reload_urlconf, User
|
||||
from importlib import reload
|
||||
import sys
|
||||
|
||||
@ -109,7 +109,6 @@ class StaffUsersOnlyTestCase(StaffUserTestCaseMixin, TestCase):
|
||||
"""When HELPDESK_ALLOW_NON_STAFF_TICKET_UPDATE is False,
|
||||
staff users should be able to access the dashboard.
|
||||
"""
|
||||
from helpdesk.decorators import is_helpdesk_staff
|
||||
|
||||
user = get_staff_user()
|
||||
self.client.login(username=user.username, password='password')
|
||||
@ -120,8 +119,6 @@ class StaffUsersOnlyTestCase(StaffUserTestCaseMixin, TestCase):
|
||||
"""When HELPDESK_ALLOW_NON_STAFF_TICKET_UPDATE is False,
|
||||
non-staff users should not be able to access the dashboard.
|
||||
"""
|
||||
from helpdesk.decorators import is_helpdesk_staff
|
||||
|
||||
user = self.non_staff_user
|
||||
self.client.login(username=user.username,
|
||||
password=self.non_staff_user_password)
|
||||
|
@ -3,7 +3,7 @@ from django.test import TestCase
|
||||
from django.urls import reverse
|
||||
from helpdesk.models import KBCategory, KBItem, Queue, Ticket
|
||||
from helpdesk.query import query_to_base64
|
||||
from helpdesk.tests.helpers import create_ticket, get_staff_user, print_response, reload_urlconf, User
|
||||
from helpdesk.tests.helpers import get_staff_user
|
||||
|
||||
|
||||
class QueryTests(TestCase):
|
||||
|
@ -1,25 +1,12 @@
|
||||
|
||||
import datetime
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.contrib.auth.hashers import make_password
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.sites.models import Site
|
||||
from django.core import mail
|
||||
from django.test import TestCase
|
||||
from django.test.client import Client
|
||||
from django.urls import reverse
|
||||
from helpdesk import settings as helpdesk_settings
|
||||
from helpdesk.models import FollowUp, Queue, Ticket
|
||||
from helpdesk.templatetags.ticket_to_link import num_to_link
|
||||
import uuid
|
||||
|
||||
|
||||
try: # python 3
|
||||
from urllib.parse import urlparse
|
||||
except ImportError: # python 2
|
||||
from urlparse import urlparse
|
||||
|
||||
|
||||
class TimeSpentTestCase(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
@ -1,15 +1,6 @@
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.core import mail
|
||||
from django.test import TestCase
|
||||
from django.test.client import Client
|
||||
from django.urls import reverse
|
||||
from helpdesk.models import CustomField, Queue, Ticket
|
||||
|
||||
|
||||
try: # python 3
|
||||
from urllib.parse import urlparse
|
||||
except ImportError: # python 2
|
||||
from urlparse import urlparse
|
||||
|
||||
|
||||
class TicketActionsTestCase(TestCase):
|
||||
|
@ -28,7 +28,7 @@ def validate_file_extension(value):
|
||||
valid_extensions = ['.txt', '.asc', '.htm', '.html',
|
||||
'.pdf', '.doc', '.docx', '.odt', '.jpg', '.png', '.eml']
|
||||
|
||||
if not ext.lower() in valid_extensions:
|
||||
if ext.lower() not in valid_extensions:
|
||||
# TODO: one more check in case it is a file with no extension; we
|
||||
# should always allow that?
|
||||
if not (ext.lower() == '' or ext.lower() == '.'):
|
||||
|
@ -1340,7 +1340,7 @@ def ticket_list(request):
|
||||
('kbitem', 'kbitem__isnull'),
|
||||
])
|
||||
for param, filter_command in filter_in_params:
|
||||
if not request.GET.get(param) is None:
|
||||
if request.GET.get(param) is not None:
|
||||
patterns = request.GET.getlist(param)
|
||||
try:
|
||||
pattern_pks = [int(pattern) for pattern in patterns]
|
||||
|
2
pyproject.toml
Normal file
2
pyproject.toml
Normal file
@ -0,0 +1,2 @@
|
||||
[tool.ruff]
|
||||
ignore = ["E501", "E731", "F841", "E721"]
|
@ -1,6 +1,5 @@
|
||||
tox
|
||||
autopep8
|
||||
flake8
|
||||
ruff
|
||||
pycodestyle
|
||||
isort
|
||||
freezegun
|
||||
|
Loading…
Reference in New Issue
Block a user