From 49789b784183873a9deca550ac82ebb461a43967 Mon Sep 17 00:00:00 2001 From: Zhiwei Date: Thu, 26 May 2022 04:48:32 -0500 Subject: [PATCH] Clean Up Black and Isort Config (#2449) Co-authored-by: Adam Hopkins --- .black.toml | 2 -- Makefile | 6 +++--- pyproject.toml | 15 +++++++++++++++ setup.cfg | 11 ----------- tests/test_asgi.py | 2 +- tests/test_blueprint_group.py | 7 +------ tests/test_blueprints.py | 7 +------ tests/test_exceptions_handler.py | 2 +- tox.ini | 4 ++-- 9 files changed, 24 insertions(+), 32 deletions(-) delete mode 100644 .black.toml diff --git a/.black.toml b/.black.toml deleted file mode 100644 index a8f43fef..00000000 --- a/.black.toml +++ /dev/null @@ -1,2 +0,0 @@ -[tool.black] -line-length = 79 diff --git a/Makefile b/Makefile index aead2544..041bc263 100644 --- a/Makefile +++ b/Makefile @@ -66,15 +66,15 @@ ifdef include_tests isort -rc sanic tests else $(info Sorting Imports) - isort -rc sanic tests --profile=black + isort -rc sanic tests endif endif black: - black --config ./.black.toml sanic tests + black sanic tests isort: - isort sanic tests --profile=black + isort sanic tests pretty: black isort diff --git a/pyproject.toml b/pyproject.toml index 01a47231..578c40c6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,18 @@ [build-system] requires = ["setuptools<60.0", "wheel"] build-backend = "setuptools.build_meta" + +[tool.black] +line-length = 79 + +[tool.isort] +atomic = true +default_section = "THIRDPARTY" +include_trailing_comma = true +known_first_party = "sanic" +known_third_party = "pytest" +line_length = 79 +lines_after_imports = 2 +lines_between_types = 1 +multi_line_output = 3 +profile = "black" diff --git a/setup.cfg b/setup.cfg index 2c573b6f..8434b4bc 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,13 +1,2 @@ [flake8] ignore = E203, W503 - -[isort] -atomic = true -default_section = THIRDPARTY -include_trailing_comma = true -known_first_party = sanic -known_third_party = pytest -line_length = 79 -lines_after_imports = 2 -lines_between_types = 1 -multi_line_output = 3 diff --git a/tests/test_asgi.py b/tests/test_asgi.py index c51c657f..49bd732b 100644 --- a/tests/test_asgi.py +++ b/tests/test_asgi.py @@ -9,7 +9,7 @@ import uvicorn from sanic import Sanic from sanic.application.state import Mode from sanic.asgi import MockTransport -from sanic.exceptions import Forbidden, BadRequest, ServiceUnavailable +from sanic.exceptions import BadRequest, Forbidden, ServiceUnavailable from sanic.request import Request from sanic.response import json, text from sanic.server.websockets.connection import WebSocketConnection diff --git a/tests/test_blueprint_group.py b/tests/test_blueprint_group.py index 4c99b42b..4321848d 100644 --- a/tests/test_blueprint_group.py +++ b/tests/test_blueprint_group.py @@ -3,12 +3,7 @@ from pytest import raises from sanic.app import Sanic from sanic.blueprint_group import BlueprintGroup from sanic.blueprints import Blueprint -from sanic.exceptions import ( - Forbidden, - BadRequest, - SanicException, - ServerError, -) +from sanic.exceptions import BadRequest, Forbidden, SanicException, ServerError from sanic.request import Request from sanic.response import HTTPResponse, text diff --git a/tests/test_blueprints.py b/tests/test_blueprints.py index 543d472b..8cf72e09 100644 --- a/tests/test_blueprints.py +++ b/tests/test_blueprints.py @@ -7,12 +7,7 @@ import pytest from sanic.app import Sanic from sanic.blueprints import Blueprint from sanic.constants import HTTP_METHODS -from sanic.exceptions import ( - BadRequest, - NotFound, - SanicException, - ServerError, -) +from sanic.exceptions import BadRequest, NotFound, SanicException, ServerError from sanic.request import Request from sanic.response import json, text diff --git a/tests/test_exceptions_handler.py b/tests/test_exceptions_handler.py index 534a6d14..78f79388 100644 --- a/tests/test_exceptions_handler.py +++ b/tests/test_exceptions_handler.py @@ -10,7 +10,7 @@ from bs4 import BeautifulSoup from pytest import LogCaptureFixture, MonkeyPatch from sanic import Sanic, handlers -from sanic.exceptions import Forbidden, BadRequest, NotFound, ServerError +from sanic.exceptions import BadRequest, Forbidden, NotFound, ServerError from sanic.handlers import ErrorHandler from sanic.request import Request from sanic.response import stream, text diff --git a/tox.ini b/tox.ini index 0eeb2561..6c4bbdbe 100644 --- a/tox.ini +++ b/tox.ini @@ -19,8 +19,8 @@ commands = [testenv:lint] commands = flake8 sanic - black --config ./.black.toml --check --verbose sanic/ - isort --check-only sanic --profile=black + black --check --verbose sanic/ + isort --check-only sanic slotscheck --verbose -m sanic [testenv:type-checking]