From 55a5ab4be154c35e51dced58ea12e9ca21786821 Mon Sep 17 00:00:00 2001 From: Adam Hopkins Date: Mon, 15 Feb 2021 14:01:32 +0200 Subject: [PATCH] squash --- Makefile | 4 ++-- sanic/app.py | 4 ++-- sanic/mixins/routes.py | 2 +- sanic/router.py | 10 ++++++---- tests/test_requests.py | 2 -- tests/test_routes.py | 3 ++- tox.ini | 2 +- 7 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 519c74ec..8361ba1b 100644 --- a/Makefile +++ b/Makefile @@ -63,7 +63,7 @@ ifdef include_tests isort -rc sanic tests else $(info Sorting Imports) - isort -rc sanic tests + isort -rc sanic tests --profile=black endif endif @@ -71,7 +71,7 @@ black: black --config ./.black.toml sanic tests fix-import: black - isort sanic tests + isort sanic tests --profile=black docs-clean: diff --git a/sanic/app.py b/sanic/app.py index 26ade2b9..c676d952 100644 --- a/sanic/app.py +++ b/sanic/app.py @@ -14,8 +14,8 @@ from traceback import format_exc from typing import Any, Dict, Iterable, List, Optional, Set, Type, Union from urllib.parse import urlencode, urlunparse -from sanic_routing.exceptions import FinalizationError -from sanic_routing.route import Route +from sanic_routing.exceptions import FinalizationError # type: ignore +from sanic_routing.route import Route # type: ignore from sanic import reloader_helpers from sanic.asgi import ASGIApp diff --git a/sanic/mixins/routes.py b/sanic/mixins/routes.py index 878bd9eb..93ee1001 100644 --- a/sanic/mixins/routes.py +++ b/sanic/mixins/routes.py @@ -2,7 +2,7 @@ from inspect import signature from pathlib import PurePath from typing import Set, Union -from sanic_routing.route import Route +from sanic_routing.route import Route # type: ignore from sanic.constants import HTTP_METHODS from sanic.models.futures import FutureRoute, FutureStatic diff --git a/sanic/router.py b/sanic/router.py index f82460d4..7325a3d8 100644 --- a/sanic/router.py +++ b/sanic/router.py @@ -1,10 +1,12 @@ from functools import lru_cache from typing import Iterable, List, Optional, Union -from sanic_routing import BaseRouter -from sanic_routing.exceptions import NoMethod -from sanic_routing.exceptions import NotFound as RoutingNotFound -from sanic_routing.route import Route +from sanic_routing import BaseRouter # type: ignore +from sanic_routing.exceptions import NoMethod # type: ignore +from sanic_routing.exceptions import ( + NotFound as RoutingNotFound, # type: ignore +) +from sanic_routing.route import Route # type: ignore from sanic.constants import HTTP_METHODS from sanic.exceptions import MethodNotSupported, NotFound diff --git a/tests/test_requests.py b/tests/test_requests.py index 67ebddd0..655a4079 100644 --- a/tests/test_requests.py +++ b/tests/test_requests.py @@ -7,11 +7,9 @@ from json import loads as json_loads from urllib.parse import urlparse import pytest -import ujson from sanic_testing.testing import ( ASGI_BASE_URL, - ASGI_HOST, ASGI_PORT, HOST, PORT, diff --git a/tests/test_routes.py b/tests/test_routes.py index ebace778..e0591913 100644 --- a/tests/test_routes.py +++ b/tests/test_routes.py @@ -161,9 +161,10 @@ def test_matching(path, headers, expected): request = Request(path, headers, None, "GET", None, app) try: + app.router.get(request=request) except NotFound: response = 404 - except Exception as e: + except Exception: response = 500 else: response = 200 diff --git a/tox.ini b/tox.ini index 6ead9ae8..b4f99e21 100644 --- a/tox.ini +++ b/tox.ini @@ -35,7 +35,7 @@ deps = commands = flake8 sanic black --config ./.black.toml --check --verbose sanic/ - isort --check-only sanic + isort --check-only sanic --profile=black [testenv:type-checking] deps =