Skip to content

Commit 58f8164

Browse files
arturdryomovhashhar
authored andcommitted
Replace "isort" with "reorder-python-imports"
1 parent bd511a4 commit 58f8164

31 files changed

+254
-152
lines changed

.pre-commit-config.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ repos:
1111
- id: "mypy"
1212
name: "Python: types"
1313

14-
- repo: "https://github.com/PyCQA/isort"
15-
rev: "5.13.2"
14+
- repo: "https://github.com/asottile/reorder-python-imports"
15+
rev: "v3.14.0"
1616
hooks:
17-
- id: "isort"
17+
- id: "reorder-python-imports"
1818
name: "Python: imports"
19-
args: ["--profile", "black"]
19+
args: ["--py39-plus"]
2020

2121
- repo: "https://github.com/pre-commit/pre-commit-hooks"
2222
rev: "v5.0.0"

setup.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python
2-
32
# Licensed under the Apache License, Version 2.0 (the "License");
43
# you may not use this file except in compliance with the License.
54
# You may obtain a copy of the License at
@@ -11,12 +10,13 @@
1110
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1211
# See the License for the specific language governing permissions and
1312
# limitations under the License.
14-
1513
import os
1614
from codecs import open
17-
from typing import Any, Dict
15+
from typing import Any
16+
from typing import Dict
1817

19-
from setuptools import find_packages, setup
18+
from setuptools import find_packages
19+
from setuptools import setup
2020

2121
about: Dict[str, Any] = {}
2222
here = os.path.abspath(os.path.dirname(__file__))

tests/integration/conftest.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1010
# See the License for the specific language governing permissions and
1111
# limitations under the License.
12-
1312
import os
1413
import socket
1514
import subprocess
@@ -20,7 +19,9 @@
2019
import pytest
2120

2221
import trino.logging
23-
from trino.client import ClientSession, TrinoQuery, TrinoRequest
22+
from trino.client import ClientSession
23+
from trino.client import TrinoQuery
24+
from trino.client import TrinoRequest
2425
from trino.constants import DEFAULT_PORT
2526

2627
logger = trino.logging.get_logger(__name__)

tests/integration/test_dbapi_integration.py

+11-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212
import math
1313
import time as t
1414
import uuid
15-
from datetime import date, datetime, time, timedelta, timezone
15+
from datetime import date
16+
from datetime import datetime
17+
from datetime import time
18+
from datetime import timedelta
19+
from datetime import timezone
1620
from decimal import Decimal
1721
from typing import Tuple
1822
from zoneinfo import ZoneInfo
@@ -24,8 +28,12 @@
2428
import trino
2529
from tests.integration.conftest import trino_version
2630
from trino import constants
27-
from trino.dbapi import Cursor, DescribeOutput, TimeBoundLRUCache
28-
from trino.exceptions import NotSupportedError, TrinoQueryError, TrinoUserError
31+
from trino.dbapi import Cursor
32+
from trino.dbapi import DescribeOutput
33+
from trino.dbapi import TimeBoundLRUCache
34+
from trino.exceptions import NotSupportedError
35+
from trino.exceptions import TrinoQueryError
36+
from trino.exceptions import TrinoUserError
2937
from trino.transaction import IsolationLevel
3038

3139

tests/integration/test_sqlalchemy_integration.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@
1515

1616
import pytest
1717
import sqlalchemy as sqla
18-
from sqlalchemy.sql import and_, not_, or_
18+
from sqlalchemy.sql import and_
19+
from sqlalchemy.sql import not_
20+
from sqlalchemy.sql import or_
1921
from sqlalchemy.types import ARRAY
2022

2123
from tests.integration.conftest import trino_version
2224
from tests.unit.conftest import sqlalchemy_version
23-
from trino.sqlalchemy.datatype import JSON, MAP, ROW
25+
from trino.sqlalchemy.datatype import JSON
26+
from trino.sqlalchemy.datatype import MAP
27+
from trino.sqlalchemy.datatype import ROW
2428

2529

2630
@pytest.fixture

tests/integration/test_types_integration.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import math
22
import re
33
import uuid
4-
from datetime import date, datetime, time, timedelta, timezone, tzinfo
4+
from datetime import date
5+
from datetime import datetime
6+
from datetime import time
7+
from datetime import timedelta
8+
from datetime import timezone
9+
from datetime import tzinfo
510
from decimal import Decimal
611
from zoneinfo import ZoneInfo
712

tests/unit/conftest.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1010
# See the License for the specific language governing permissions and
1111
# limitations under the License.
12-
13-
from unittest.mock import MagicMock, patch
12+
from unittest.mock import MagicMock
13+
from unittest.mock import patch
1414

1515
import pytest
1616

tests/unit/oauth_test_utils.py

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1010
# See the License for the specific language governing permissions and
1111
# limitations under the License.
12-
1312
import json
1413
import re
1514
import uuid

tests/unit/sqlalchemy/conftest.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212
import pytest
1313
from sqlalchemy.sql.sqltypes import ARRAY
1414

15-
from trino.sqlalchemy.datatype import MAP, ROW, TIME, TIMESTAMP, SQLType
15+
from trino.sqlalchemy.datatype import MAP
16+
from trino.sqlalchemy.datatype import ROW
17+
from trino.sqlalchemy.datatype import SQLType
18+
from trino.sqlalchemy.datatype import TIME
19+
from trino.sqlalchemy.datatype import TIMESTAMP
1620

1721

1822
@pytest.fixture(scope="session")

tests/unit/sqlalchemy/test_compiler.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,17 @@
1010
# See the License for the specific language governing permissions and
1111
# limitations under the License.
1212
import pytest
13-
from sqlalchemy import Column, Integer, MetaData, String, Table, func, insert, select
13+
from sqlalchemy import Column
14+
from sqlalchemy import func
15+
from sqlalchemy import insert
16+
from sqlalchemy import Integer
17+
from sqlalchemy import MetaData
18+
from sqlalchemy import select
19+
from sqlalchemy import String
20+
from sqlalchemy import Table
1421
from sqlalchemy.schema import CreateTable
15-
from sqlalchemy.sql import column, table
22+
from sqlalchemy.sql import column
23+
from sqlalchemy.sql import table
1624

1725
from tests.unit.conftest import sqlalchemy_version
1826
from trino.sqlalchemy.dialect import TrinoDialect

tests/unit/sqlalchemy/test_datatype_parse.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,19 @@
1111
# limitations under the License.
1212
import pytest
1313
from sqlalchemy.exc import UnsupportedCompilationError
14-
from sqlalchemy.sql.sqltypes import ARRAY, CHAR, DATE, DECIMAL, INTEGER, VARCHAR
14+
from sqlalchemy.sql.sqltypes import ARRAY
15+
from sqlalchemy.sql.sqltypes import CHAR
16+
from sqlalchemy.sql.sqltypes import DATE
17+
from sqlalchemy.sql.sqltypes import DECIMAL
18+
from sqlalchemy.sql.sqltypes import INTEGER
19+
from sqlalchemy.sql.sqltypes import VARCHAR
1520
from sqlalchemy.sql.type_api import TypeEngine
1621

1722
from trino.sqlalchemy import datatype
18-
from trino.sqlalchemy.datatype import MAP, ROW, TIME, TIMESTAMP
23+
from trino.sqlalchemy.datatype import MAP
24+
from trino.sqlalchemy.datatype import ROW
25+
from trino.sqlalchemy.datatype import TIME
26+
from trino.sqlalchemy.datatype import TIMESTAMP
1927

2028

2129
@pytest.mark.parametrize(

tests/unit/sqlalchemy/test_dialect.py

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
from typing import Any, Dict, List
1+
from typing import Any
2+
from typing import Dict
3+
from typing import List
24
from unittest import mock
35

46
import pytest
5-
from sqlalchemy.engine.url import URL, make_url
7+
from sqlalchemy.engine.url import make_url
8+
from sqlalchemy.engine.url import URL
69

7-
from trino.auth import BasicAuthentication, OAuth2Authentication
10+
from trino.auth import BasicAuthentication
11+
from trino.auth import OAuth2Authentication
812
from trino.dbapi import Connection
913
from trino.sqlalchemy import URL as trino_url
10-
from trino.sqlalchemy.dialect import (
11-
CertificateAuthentication,
12-
JWTAuthentication,
13-
TrinoDialect,
14-
)
14+
from trino.sqlalchemy.dialect import CertificateAuthentication
15+
from trino.sqlalchemy.dialect import JWTAuthentication
16+
from trino.sqlalchemy.dialect import TrinoDialect
1517
from trino.transaction import IsolationLevel
1618

1719

tests/unit/test_client.py

+28-30
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@
1515
import urllib
1616
import uuid
1717
from contextlib import nullcontext as does_not_raise
18-
from typing import Any, Dict, Optional
19-
from unittest import TestCase, mock
18+
from typing import Any
19+
from typing import Dict
20+
from typing import Optional
21+
from unittest import mock
22+
from unittest import TestCase
2023
from urllib.parse import urlparse
2124
from zoneinfo import ZoneInfoNotFoundError
2225

@@ -31,34 +34,29 @@
3134
from tzlocal import get_localzone_name # type: ignore
3235

3336
import trino.exceptions
34-
from tests.unit.oauth_test_utils import (
35-
REDIRECT_RESOURCE,
36-
SERVER_ADDRESS,
37-
TOKEN_RESOURCE,
38-
GetTokenCallback,
39-
MultithreadedTokenServer,
40-
PostStatementCallback,
41-
RedirectHandler,
42-
RedirectHandlerWithException,
43-
_get_token_requests,
44-
_post_statement_requests,
45-
)
46-
from trino import __version__, constants
47-
from trino.auth import (
48-
GSSAPIAuthentication,
49-
KerberosAuthentication,
50-
_OAuth2KeyRingTokenCache,
51-
_OAuth2TokenBearer,
52-
)
53-
from trino.client import (
54-
ClientSession,
55-
TrinoQuery,
56-
TrinoRequest,
57-
TrinoResult,
58-
_DelayExponential,
59-
_retry_with,
60-
_RetryWithExponentialBackoff,
61-
)
37+
from tests.unit.oauth_test_utils import _get_token_requests
38+
from tests.unit.oauth_test_utils import _post_statement_requests
39+
from tests.unit.oauth_test_utils import GetTokenCallback
40+
from tests.unit.oauth_test_utils import MultithreadedTokenServer
41+
from tests.unit.oauth_test_utils import PostStatementCallback
42+
from tests.unit.oauth_test_utils import REDIRECT_RESOURCE
43+
from tests.unit.oauth_test_utils import RedirectHandler
44+
from tests.unit.oauth_test_utils import RedirectHandlerWithException
45+
from tests.unit.oauth_test_utils import SERVER_ADDRESS
46+
from tests.unit.oauth_test_utils import TOKEN_RESOURCE
47+
from trino import __version__
48+
from trino import constants
49+
from trino.auth import _OAuth2KeyRingTokenCache
50+
from trino.auth import _OAuth2TokenBearer
51+
from trino.auth import GSSAPIAuthentication
52+
from trino.auth import KerberosAuthentication
53+
from trino.client import _DelayExponential
54+
from trino.client import _retry_with
55+
from trino.client import _RetryWithExponentialBackoff
56+
from trino.client import ClientSession
57+
from trino.client import TrinoQuery
58+
from trino.client import TrinoRequest
59+
from trino.client import TrinoResult
6260

6361

6462
@mock.patch("trino.client.TrinoRequest.http")

tests/unit/test_dbapi.py

+10-11
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,18 @@
1717
from httpretty import httprettified
1818
from requests import Session
1919

20-
from tests.unit.oauth_test_utils import (
21-
REDIRECT_RESOURCE,
22-
SERVER_ADDRESS,
23-
TOKEN_RESOURCE,
24-
GetTokenCallback,
25-
PostStatementCallback,
26-
RedirectHandler,
27-
_get_token_requests,
28-
_post_statement_requests,
29-
)
20+
from tests.unit.oauth_test_utils import _get_token_requests
21+
from tests.unit.oauth_test_utils import _post_statement_requests
22+
from tests.unit.oauth_test_utils import GetTokenCallback
23+
from tests.unit.oauth_test_utils import PostStatementCallback
24+
from tests.unit.oauth_test_utils import REDIRECT_RESOURCE
25+
from tests.unit.oauth_test_utils import RedirectHandler
26+
from tests.unit.oauth_test_utils import SERVER_ADDRESS
27+
from tests.unit.oauth_test_utils import TOKEN_RESOURCE
3028
from trino import constants
3129
from trino.auth import OAuth2Authentication
32-
from trino.dbapi import Connection, connect
30+
from trino.dbapi import connect
31+
from trino.dbapi import Connection
3332

3433

3534
@patch("trino.dbapi.trino.client")

tests/unit/test_http.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,11 @@
99
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1010
# See the License for the specific language governing permissions and
1111
# limitations under the License.
12-
1312
from trino import constants
14-
from trino.client import (
15-
get_header_values,
16-
get_prepared_statement_values,
17-
get_roles_values,
18-
get_session_property_values,
19-
)
13+
from trino.client import get_header_values
14+
from trino.client import get_prepared_statement_values
15+
from trino.client import get_roles_values
16+
from trino.client import get_session_property_values
2017

2118

2219
def test_get_header_values():

tests/unit/test_transaction.py

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1010
# See the License for the specific language governing permissions and
1111
# limitations under the License.
12-
1312
import pytest
1413

1514
from trino.transaction import IsolationLevel

tests/unit/test_types.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1010
# See the License for the specific language governing permissions and
1111
# limitations under the License.
12-
1312
import pickle
14-
from datetime import datetime, time
13+
from datetime import datetime
14+
from datetime import time
1515
from decimal import Decimal
1616

1717
import pytest

trino/__init__.py

+13-11
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,19 @@
99
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1010
# See the License for the specific language governing permissions and
1111
# limitations under the License.
12-
13-
from . import auth, client, constants, dbapi, exceptions, logging
14-
from ._version import (
15-
__author__,
16-
__author_email__,
17-
__description__,
18-
__license__,
19-
__title__,
20-
__url__,
21-
__version__,
22-
)
12+
from . import auth
13+
from . import client
14+
from . import constants
15+
from . import dbapi
16+
from . import exceptions
17+
from . import logging
18+
from ._version import __author__
19+
from ._version import __author_email__
20+
from ._version import __description__
21+
from ._version import __license__
22+
from ._version import __title__
23+
from ._version import __url__
24+
from ._version import __version__
2325

2426
__all__ = [
2527
"auth",

0 commit comments

Comments
 (0)