diff --git a/requirements-test.txt b/requirements-test.txt index cda155f8..3af04370 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1,8 +1,9 @@ pytest pytest-django pytest-mock swh.scheduler[testing] swh.loader.core[testing] pytest-postgresql >= 2.1.0 requests_mock django-stubs +djangorestframework-stubs >= 1.4 diff --git a/swh/deposit/urls.py b/swh/deposit/urls.py index d5d2fc68..22c5a4c6 100644 --- a/swh/deposit/urls.py +++ b/swh/deposit/urls.py @@ -1,31 +1,35 @@ # Copyright (C) 2017-2019 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information """SWH's main deposit URL Configuration """ +from typing import Sequence, Union + from django.conf.urls import include, url from django.shortcuts import render +from django.urls import URLPattern, URLResolver from django.views.generic.base import RedirectView from rest_framework.urlpatterns import format_suffix_patterns favicon_view = RedirectView.as_view( url="/static/img/icons/swh-logo-32x32.png", permanent=True ) def default_view(req): return render(req, "homepage.html") -urlpatterns = [ - url(r"^favicon\.ico$", favicon_view), - url(r"^1/", include("swh.deposit.api.urls")), - url(r"^1/private/", include("swh.deposit.api.private.urls")), - url(r"^$", default_view, name="home"), -] - -urlpatterns = format_suffix_patterns(urlpatterns) # type: ignore +urlpatterns: Sequence[Union[URLPattern, URLResolver]] +urlpatterns = format_suffix_patterns( + [ + url(r"^favicon\.ico$", favicon_view), + url(r"^1/", include("swh.deposit.api.urls")), + url(r"^1/private/", include("swh.deposit.api.private.urls")), + url(r"^$", default_view, name="home"), + ] +) diff --git a/tox.ini b/tox.ini index f9d945e7..12c11f50 100644 --- a/tox.ini +++ b/tox.ini @@ -1,45 +1,43 @@ [tox] envlist=flake8,mypy,py3-django2 [testenv] extras = testing deps = # the dependency below is needed for now as a workaround for # https://github.com/pypa/pip/issues/6239 swh.core[http] >= 0.3 swh.scheduler[testing] >= 0.5.0 dev: pdbpp pytest-cov django2: Django>=2,<3 commands = pytest \ !dev: --cov {envsitepackagesdir}/swh/deposit --cov-branch \ {envsitepackagesdir}/swh/deposit \ {posargs} [testenv:black] skip_install = true deps = black==19.10b0 commands = {envpython} -m black --check swh [testenv:flake8] skip_install = true deps = flake8 commands = {envpython} -m flake8 \ --exclude=.tox,.git,__pycache__,.tox,.eggs,*.egg,swh/deposit/migrations [testenv:mypy] setenv = DJANGO_SETTINGS_MODULE=swh.deposit.settings.testing extras = testing deps = mypy - django-stubs - djangorestframework-stubs >= 1.3.0 commands = mypy swh