Skip to content

Commit

Permalink
Replace "isort" with "reorder-python-imports"
Browse files Browse the repository at this point in the history
  • Loading branch information
arturdryomov authored and hashhar committed Dec 13, 2024
1 parent bd511a4 commit 58f8164
Show file tree
Hide file tree
Showing 31 changed files with 254 additions and 152 deletions.
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ repos:
- id: "mypy"
name: "Python: types"

- repo: "https://github.com/PyCQA/isort"
rev: "5.13.2"
- repo: "https://github.com/asottile/reorder-python-imports"
rev: "v3.14.0"
hooks:
- id: "isort"
- id: "reorder-python-imports"
name: "Python: imports"
args: ["--profile", "black"]
args: ["--py39-plus"]

- repo: "https://github.com/pre-commit/pre-commit-hooks"
rev: "v5.0.0"
Expand Down
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
Expand All @@ -11,12 +10,13 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import os
from codecs import open
from typing import Any, Dict
from typing import Any
from typing import Dict

from setuptools import find_packages, setup
from setuptools import find_packages
from setuptools import setup

about: Dict[str, Any] = {}
here = os.path.abspath(os.path.dirname(__file__))
Expand Down
5 changes: 3 additions & 2 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import socket
import subprocess
Expand All @@ -20,7 +19,9 @@
import pytest

import trino.logging
from trino.client import ClientSession, TrinoQuery, TrinoRequest
from trino.client import ClientSession
from trino.client import TrinoQuery
from trino.client import TrinoRequest
from trino.constants import DEFAULT_PORT

logger = trino.logging.get_logger(__name__)
Expand Down
14 changes: 11 additions & 3 deletions tests/integration/test_dbapi_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
import math
import time as t
import uuid
from datetime import date, datetime, time, timedelta, timezone
from datetime import date
from datetime import datetime
from datetime import time
from datetime import timedelta
from datetime import timezone
from decimal import Decimal
from typing import Tuple
from zoneinfo import ZoneInfo
Expand All @@ -24,8 +28,12 @@
import trino
from tests.integration.conftest import trino_version
from trino import constants
from trino.dbapi import Cursor, DescribeOutput, TimeBoundLRUCache
from trino.exceptions import NotSupportedError, TrinoQueryError, TrinoUserError
from trino.dbapi import Cursor
from trino.dbapi import DescribeOutput
from trino.dbapi import TimeBoundLRUCache
from trino.exceptions import NotSupportedError
from trino.exceptions import TrinoQueryError
from trino.exceptions import TrinoUserError
from trino.transaction import IsolationLevel


Expand Down
8 changes: 6 additions & 2 deletions tests/integration/test_sqlalchemy_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@

import pytest
import sqlalchemy as sqla
from sqlalchemy.sql import and_, not_, or_
from sqlalchemy.sql import and_
from sqlalchemy.sql import not_
from sqlalchemy.sql import or_
from sqlalchemy.types import ARRAY

from tests.integration.conftest import trino_version
from tests.unit.conftest import sqlalchemy_version
from trino.sqlalchemy.datatype import JSON, MAP, ROW
from trino.sqlalchemy.datatype import JSON
from trino.sqlalchemy.datatype import MAP
from trino.sqlalchemy.datatype import ROW


@pytest.fixture
Expand Down
7 changes: 6 additions & 1 deletion tests/integration/test_types_integration.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import math
import re
import uuid
from datetime import date, datetime, time, timedelta, timezone, tzinfo
from datetime import date
from datetime import datetime
from datetime import time
from datetime import timedelta
from datetime import timezone
from datetime import tzinfo
from decimal import Decimal
from zoneinfo import ZoneInfo

Expand Down
4 changes: 2 additions & 2 deletions tests/unit/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from unittest.mock import MagicMock, patch
from unittest.mock import MagicMock
from unittest.mock import patch

import pytest

Expand Down
1 change: 0 additions & 1 deletion tests/unit/oauth_test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import json
import re
import uuid
Expand Down
6 changes: 5 additions & 1 deletion tests/unit/sqlalchemy/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
import pytest
from sqlalchemy.sql.sqltypes import ARRAY

from trino.sqlalchemy.datatype import MAP, ROW, TIME, TIMESTAMP, SQLType
from trino.sqlalchemy.datatype import MAP
from trino.sqlalchemy.datatype import ROW
from trino.sqlalchemy.datatype import SQLType
from trino.sqlalchemy.datatype import TIME
from trino.sqlalchemy.datatype import TIMESTAMP


@pytest.fixture(scope="session")
Expand Down
12 changes: 10 additions & 2 deletions tests/unit/sqlalchemy/test_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from sqlalchemy import Column, Integer, MetaData, String, Table, func, insert, select
from sqlalchemy import Column
from sqlalchemy import func
from sqlalchemy import insert
from sqlalchemy import Integer
from sqlalchemy import MetaData
from sqlalchemy import select
from sqlalchemy import String
from sqlalchemy import Table
from sqlalchemy.schema import CreateTable
from sqlalchemy.sql import column, table
from sqlalchemy.sql import column
from sqlalchemy.sql import table

from tests.unit.conftest import sqlalchemy_version
from trino.sqlalchemy.dialect import TrinoDialect
Expand Down
12 changes: 10 additions & 2 deletions tests/unit/sqlalchemy/test_datatype_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,19 @@
# limitations under the License.
import pytest
from sqlalchemy.exc import UnsupportedCompilationError
from sqlalchemy.sql.sqltypes import ARRAY, CHAR, DATE, DECIMAL, INTEGER, VARCHAR
from sqlalchemy.sql.sqltypes import ARRAY
from sqlalchemy.sql.sqltypes import CHAR
from sqlalchemy.sql.sqltypes import DATE
from sqlalchemy.sql.sqltypes import DECIMAL
from sqlalchemy.sql.sqltypes import INTEGER
from sqlalchemy.sql.sqltypes import VARCHAR
from sqlalchemy.sql.type_api import TypeEngine

from trino.sqlalchemy import datatype
from trino.sqlalchemy.datatype import MAP, ROW, TIME, TIMESTAMP
from trino.sqlalchemy.datatype import MAP
from trino.sqlalchemy.datatype import ROW
from trino.sqlalchemy.datatype import TIME
from trino.sqlalchemy.datatype import TIMESTAMP


@pytest.mark.parametrize(
Expand Down
18 changes: 10 additions & 8 deletions tests/unit/sqlalchemy/test_dialect.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
from typing import Any, Dict, List
from typing import Any
from typing import Dict
from typing import List
from unittest import mock

import pytest
from sqlalchemy.engine.url import URL, make_url
from sqlalchemy.engine.url import make_url
from sqlalchemy.engine.url import URL

from trino.auth import BasicAuthentication, OAuth2Authentication
from trino.auth import BasicAuthentication
from trino.auth import OAuth2Authentication
from trino.dbapi import Connection
from trino.sqlalchemy import URL as trino_url
from trino.sqlalchemy.dialect import (
CertificateAuthentication,
JWTAuthentication,
TrinoDialect,
)
from trino.sqlalchemy.dialect import CertificateAuthentication
from trino.sqlalchemy.dialect import JWTAuthentication
from trino.sqlalchemy.dialect import TrinoDialect
from trino.transaction import IsolationLevel


Expand Down
58 changes: 28 additions & 30 deletions tests/unit/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@
import urllib
import uuid
from contextlib import nullcontext as does_not_raise
from typing import Any, Dict, Optional
from unittest import TestCase, mock
from typing import Any
from typing import Dict
from typing import Optional
from unittest import mock
from unittest import TestCase
from urllib.parse import urlparse
from zoneinfo import ZoneInfoNotFoundError

Expand All @@ -31,34 +34,29 @@
from tzlocal import get_localzone_name # type: ignore

import trino.exceptions
from tests.unit.oauth_test_utils import (
REDIRECT_RESOURCE,
SERVER_ADDRESS,
TOKEN_RESOURCE,
GetTokenCallback,
MultithreadedTokenServer,
PostStatementCallback,
RedirectHandler,
RedirectHandlerWithException,
_get_token_requests,
_post_statement_requests,
)
from trino import __version__, constants
from trino.auth import (
GSSAPIAuthentication,
KerberosAuthentication,
_OAuth2KeyRingTokenCache,
_OAuth2TokenBearer,
)
from trino.client import (
ClientSession,
TrinoQuery,
TrinoRequest,
TrinoResult,
_DelayExponential,
_retry_with,
_RetryWithExponentialBackoff,
)
from tests.unit.oauth_test_utils import _get_token_requests
from tests.unit.oauth_test_utils import _post_statement_requests
from tests.unit.oauth_test_utils import GetTokenCallback
from tests.unit.oauth_test_utils import MultithreadedTokenServer
from tests.unit.oauth_test_utils import PostStatementCallback
from tests.unit.oauth_test_utils import REDIRECT_RESOURCE
from tests.unit.oauth_test_utils import RedirectHandler
from tests.unit.oauth_test_utils import RedirectHandlerWithException
from tests.unit.oauth_test_utils import SERVER_ADDRESS
from tests.unit.oauth_test_utils import TOKEN_RESOURCE
from trino import __version__
from trino import constants
from trino.auth import _OAuth2KeyRingTokenCache
from trino.auth import _OAuth2TokenBearer
from trino.auth import GSSAPIAuthentication
from trino.auth import KerberosAuthentication
from trino.client import _DelayExponential
from trino.client import _retry_with
from trino.client import _RetryWithExponentialBackoff
from trino.client import ClientSession
from trino.client import TrinoQuery
from trino.client import TrinoRequest
from trino.client import TrinoResult


@mock.patch("trino.client.TrinoRequest.http")
Expand Down
21 changes: 10 additions & 11 deletions tests/unit/test_dbapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,18 @@
from httpretty import httprettified
from requests import Session

from tests.unit.oauth_test_utils import (
REDIRECT_RESOURCE,
SERVER_ADDRESS,
TOKEN_RESOURCE,
GetTokenCallback,
PostStatementCallback,
RedirectHandler,
_get_token_requests,
_post_statement_requests,
)
from tests.unit.oauth_test_utils import _get_token_requests
from tests.unit.oauth_test_utils import _post_statement_requests
from tests.unit.oauth_test_utils import GetTokenCallback
from tests.unit.oauth_test_utils import PostStatementCallback
from tests.unit.oauth_test_utils import REDIRECT_RESOURCE
from tests.unit.oauth_test_utils import RedirectHandler
from tests.unit.oauth_test_utils import SERVER_ADDRESS
from tests.unit.oauth_test_utils import TOKEN_RESOURCE
from trino import constants
from trino.auth import OAuth2Authentication
from trino.dbapi import Connection, connect
from trino.dbapi import connect
from trino.dbapi import Connection


@patch("trino.dbapi.trino.client")
Expand Down
11 changes: 4 additions & 7 deletions tests/unit/test_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from trino import constants
from trino.client import (
get_header_values,
get_prepared_statement_values,
get_roles_values,
get_session_property_values,
)
from trino.client import get_header_values
from trino.client import get_prepared_statement_values
from trino.client import get_roles_values
from trino.client import get_session_property_values


def test_get_header_values():
Expand Down
1 change: 0 additions & 1 deletion tests/unit/test_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import pytest

from trino.transaction import IsolationLevel
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import pickle
from datetime import datetime, time
from datetime import datetime
from datetime import time
from decimal import Decimal

import pytest
Expand Down
24 changes: 13 additions & 11 deletions trino/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,19 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from . import auth, client, constants, dbapi, exceptions, logging
from ._version import (
__author__,
__author_email__,
__description__,
__license__,
__title__,
__url__,
__version__,
)
from . import auth
from . import client
from . import constants
from . import dbapi
from . import exceptions
from . import logging
from ._version import __author__
from ._version import __author_email__
from ._version import __description__
from ._version import __license__
from ._version import __title__
from ._version import __url__
from ._version import __version__

__all__ = [
"auth",
Expand Down
Loading

0 comments on commit 58f8164

Please sign in to comment.