From 7b4dce1686c350b5802c95646acbe9380a59c80a Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Wed, 16 Feb 2022 09:56:40 +0000 Subject: [PATCH 1/2] Restyled by black --- minos/auth/config.py | 20 +++++--------------- minos/auth/database/models.py | 16 ++++------------ minos/auth/handler.py | 26 ++++++++------------------ minos/auth/service.py | 24 ++++++------------------ tests/test_auth/test_config.py | 8 ++------ tests/test_auth/test_service.py | 16 ++++------------ 6 files changed, 29 insertions(+), 81 deletions(-) diff --git a/minos/auth/config.py b/minos/auth/config.py index 8a99c75..458b18d 100644 --- a/minos/auth/config.py +++ b/minos/auth/config.py @@ -1,26 +1,16 @@ -from __future__ import ( - annotations, -) +from __future__ import annotations import abc import collections import os import typing as t -from distutils import ( - util, -) -from pathlib import ( - Path, -) -from typing import ( - Any, -) +from distutils import util +from pathlib import Path +from typing import Any import yaml -from .exceptions import ( - AuthConfigException, -) +from .exceptions import AuthConfigException REST = collections.namedtuple("Rest", "host port") DATABASE = collections.namedtuple("Database", "dbname user password host port") diff --git a/minos/auth/database/models.py b/minos/auth/database/models.py index dd1a98f..e8aaac5 100644 --- a/minos/auth/database/models.py +++ b/minos/auth/database/models.py @@ -1,7 +1,5 @@ import uuid -from enum import ( - Enum, -) +from enum import Enum from sqlalchemy import ( TIMESTAMP, @@ -10,15 +8,9 @@ Integer, String, ) -from sqlalchemy.dialects.postgresql import ( - UUID, -) -from sqlalchemy.ext.declarative import ( - declarative_base, -) -from sqlalchemy.orm import ( - relationship, -) +from sqlalchemy.dialects.postgresql import UUID +from sqlalchemy.ext.declarative import declarative_base +from sqlalchemy.orm import relationship Base = declarative_base() diff --git a/minos/auth/handler.py b/minos/auth/handler.py index 1a909a8..002766c 100644 --- a/minos/auth/handler.py +++ b/minos/auth/handler.py @@ -1,12 +1,8 @@ import json import logging import secrets -from datetime import ( - datetime, -) -from uuid import ( - uuid4, -) +from datetime import datetime +from uuid import uuid4 from aiohttp import ( ClientConnectorError, @@ -14,15 +10,9 @@ ClientSession, web, ) -from sqlalchemy import ( - desc, -) -from sqlalchemy.orm import ( - sessionmaker, -) -from yarl import ( - URL, -) +from sqlalchemy import desc +from sqlalchemy.orm import sessionmaker +from yarl import URL from .database.models import ( Authentication, @@ -187,7 +177,7 @@ async def get_token_user(request: web.Request, token: str, auth_type: AuthType): if response.status == 200: resp_json = json.loads(response.text) - resp_json['role'] = role + resp_json["role"] = role return web.json_response(resp_json) return response # pragma: no cover @@ -229,7 +219,7 @@ async def validate_token(request: web.Request) -> web.Response: if response.status == 200: resp_json = json.loads(response.text) - resp_json['role'] = role + resp_json["role"] = role return web.json_response(resp_json) return response # pragma: no cover @@ -238,7 +228,7 @@ async def validate_token(request: web.Request) -> web.Response: if response.status == 200: resp_json = json.loads(response.text) - resp_json['role'] = role + resp_json["role"] = role return web.json_response(resp_json) return response # pragma: no cover diff --git a/minos/auth/service.py b/minos/auth/service.py index c723c19..ab0eb91 100644 --- a/minos/auth/service.py +++ b/minos/auth/service.py @@ -1,24 +1,12 @@ import logging -from datetime import ( - datetime, -) +from datetime import datetime -from aiohttp import ( - web, -) -from aiomisc.service.aiohttp import ( - AIOHTTPService, -) -from sqlalchemy import ( - create_engine, -) -from sqlalchemy.orm import ( - sessionmaker, -) +from aiohttp import web +from aiomisc.service.aiohttp import AIOHTTPService +from sqlalchemy import create_engine +from sqlalchemy.orm import sessionmaker -from .config import ( - AuthConfig, -) +from .config import AuthConfig from .database.models import ( Base, Role, diff --git a/tests/test_auth/test_config.py b/tests/test_auth/test_config.py index 57aed67..6f364a2 100644 --- a/tests/test_auth/test_config.py +++ b/tests/test_auth/test_config.py @@ -7,17 +7,13 @@ """ import os import unittest -from unittest import ( - mock, -) +from unittest import mock from minos.auth import ( AuthConfig, AuthConfigException, ) -from tests.utils import ( - BASE_PATH, -) +from tests.utils import BASE_PATH class TestApiGatewayConfig(unittest.TestCase): diff --git a/tests/test_auth/test_service.py b/tests/test_auth/test_service.py index e835e7a..fcb990d 100644 --- a/tests/test_auth/test_service.py +++ b/tests/test_auth/test_service.py @@ -1,25 +1,17 @@ """tests.test_api_gateway.test_rest.service module.""" import json import unittest -from uuid import ( - uuid4, -) +from uuid import uuid4 import aiohttp -from aiohttp.test_utils import ( - AioHTTPTestCase, -) +from aiohttp.test_utils import AioHTTPTestCase from minos.auth import ( AuthConfig, AuthRestService, ) -from tests.mock_servers.server import ( - MockServer, -) -from tests.utils import ( - BASE_PATH, -) +from tests.mock_servers.server import MockServer +from tests.utils import BASE_PATH class TestAuthRestService(AioHTTPTestCase): From 984a0c2dd767aaa2f464d27fd3ff7ae6c2913bd0 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Wed, 16 Feb 2022 09:56:41 +0000 Subject: [PATCH 2/2] Restyled by isort --- minos/auth/config.py | 20 +++++++++++++++----- minos/auth/database/models.py | 16 ++++++++++++---- minos/auth/handler.py | 20 +++++++++++++++----- minos/auth/service.py | 24 ++++++++++++++++++------ tests/test_auth/test_config.py | 8 ++++++-- tests/test_auth/test_service.py | 16 ++++++++++++---- 6 files changed, 78 insertions(+), 26 deletions(-) diff --git a/minos/auth/config.py b/minos/auth/config.py index 458b18d..8a99c75 100644 --- a/minos/auth/config.py +++ b/minos/auth/config.py @@ -1,16 +1,26 @@ -from __future__ import annotations +from __future__ import ( + annotations, +) import abc import collections import os import typing as t -from distutils import util -from pathlib import Path -from typing import Any +from distutils import ( + util, +) +from pathlib import ( + Path, +) +from typing import ( + Any, +) import yaml -from .exceptions import AuthConfigException +from .exceptions import ( + AuthConfigException, +) REST = collections.namedtuple("Rest", "host port") DATABASE = collections.namedtuple("Database", "dbname user password host port") diff --git a/minos/auth/database/models.py b/minos/auth/database/models.py index e8aaac5..dd1a98f 100644 --- a/minos/auth/database/models.py +++ b/minos/auth/database/models.py @@ -1,5 +1,7 @@ import uuid -from enum import Enum +from enum import ( + Enum, +) from sqlalchemy import ( TIMESTAMP, @@ -8,9 +10,15 @@ Integer, String, ) -from sqlalchemy.dialects.postgresql import UUID -from sqlalchemy.ext.declarative import declarative_base -from sqlalchemy.orm import relationship +from sqlalchemy.dialects.postgresql import ( + UUID, +) +from sqlalchemy.ext.declarative import ( + declarative_base, +) +from sqlalchemy.orm import ( + relationship, +) Base = declarative_base() diff --git a/minos/auth/handler.py b/minos/auth/handler.py index 002766c..3b4a581 100644 --- a/minos/auth/handler.py +++ b/minos/auth/handler.py @@ -1,8 +1,12 @@ import json import logging import secrets -from datetime import datetime -from uuid import uuid4 +from datetime import ( + datetime, +) +from uuid import ( + uuid4, +) from aiohttp import ( ClientConnectorError, @@ -10,9 +14,15 @@ ClientSession, web, ) -from sqlalchemy import desc -from sqlalchemy.orm import sessionmaker -from yarl import URL +from sqlalchemy import ( + desc, +) +from sqlalchemy.orm import ( + sessionmaker, +) +from yarl import ( + URL, +) from .database.models import ( Authentication, diff --git a/minos/auth/service.py b/minos/auth/service.py index ab0eb91..c723c19 100644 --- a/minos/auth/service.py +++ b/minos/auth/service.py @@ -1,12 +1,24 @@ import logging -from datetime import datetime +from datetime import ( + datetime, +) -from aiohttp import web -from aiomisc.service.aiohttp import AIOHTTPService -from sqlalchemy import create_engine -from sqlalchemy.orm import sessionmaker +from aiohttp import ( + web, +) +from aiomisc.service.aiohttp import ( + AIOHTTPService, +) +from sqlalchemy import ( + create_engine, +) +from sqlalchemy.orm import ( + sessionmaker, +) -from .config import AuthConfig +from .config import ( + AuthConfig, +) from .database.models import ( Base, Role, diff --git a/tests/test_auth/test_config.py b/tests/test_auth/test_config.py index 6f364a2..57aed67 100644 --- a/tests/test_auth/test_config.py +++ b/tests/test_auth/test_config.py @@ -7,13 +7,17 @@ """ import os import unittest -from unittest import mock +from unittest import ( + mock, +) from minos.auth import ( AuthConfig, AuthConfigException, ) -from tests.utils import BASE_PATH +from tests.utils import ( + BASE_PATH, +) class TestApiGatewayConfig(unittest.TestCase): diff --git a/tests/test_auth/test_service.py b/tests/test_auth/test_service.py index fcb990d..e835e7a 100644 --- a/tests/test_auth/test_service.py +++ b/tests/test_auth/test_service.py @@ -1,17 +1,25 @@ """tests.test_api_gateway.test_rest.service module.""" import json import unittest -from uuid import uuid4 +from uuid import ( + uuid4, +) import aiohttp -from aiohttp.test_utils import AioHTTPTestCase +from aiohttp.test_utils import ( + AioHTTPTestCase, +) from minos.auth import ( AuthConfig, AuthRestService, ) -from tests.mock_servers.server import MockServer -from tests.utils import BASE_PATH +from tests.mock_servers.server import ( + MockServer, +) +from tests.utils import ( + BASE_PATH, +) class TestAuthRestService(AioHTTPTestCase):