Skip to content

Commit d105f0b

Browse files
committed
Sort imports using isort
1 parent de61749 commit d105f0b

24 files changed

+77
-73
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import re
1717
import textwrap
1818

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

2121
_version_re = re.compile(r"__version__\s+=\s+(.*)")
2222

tests/integration/conftest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
from uuid import uuid4
1919

2020
import click
21-
import trino.logging
2221
import pytest
23-
from trino.client import TrinoQuery, TrinoRequest, ClientSession
24-
from trino.constants import DEFAULT_PORT
2522

23+
import trino.logging
24+
from trino.client import ClientSession, TrinoQuery, TrinoRequest
25+
from trino.constants import DEFAULT_PORT
2626

2727
logger = trino.logging.get_logger(__name__)
2828

tests/integration/test_dbapi_integration.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# See the License for the specific language governing permissions and
1111
# limitations under the License.
1212
import math
13-
from datetime import datetime, time, date, timezone, timedelta
13+
from datetime import date, datetime, time, timedelta, timezone
1414
from decimal import Decimal
1515

1616
import pytest
@@ -20,7 +20,7 @@
2020
import trino
2121
from tests.integration.conftest import trino_version
2222
from trino import constants
23-
from trino.exceptions import TrinoQueryError, TrinoUserError, NotSupportedError
23+
from trino.exceptions import NotSupportedError, TrinoQueryError, TrinoUserError
2424
from trino.transaction import IsolationLevel
2525

2626

tests/integration/test_sqlalchemy_integration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# limitations under the License
1212
import pytest
1313
import sqlalchemy as sqla
14-
from sqlalchemy.sql import and_, or_, not_
14+
from sqlalchemy.sql import and_, not_, or_
1515

1616
from tests.unit.conftest import sqlalchemy_version
1717
from trino.sqlalchemy.datatype import JSON

tests/integration/test_types_integration.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import math
2-
import pytest
32
from decimal import Decimal
3+
4+
import pytest
5+
46
import trino
57

68

tests/unit/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
# See the License for the specific language governing permissions and
1111
# limitations under the License.
1212

13-
import pytest
1413
from unittest.mock import MagicMock, patch
1514

15+
import pytest
16+
1617

1718
@pytest.fixture(scope="session")
1819
def sample_post_response_data():

tests/unit/sqlalchemy/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import pytest
1313
from sqlalchemy.sql.sqltypes import ARRAY
1414

15-
from trino.sqlalchemy.datatype import MAP, ROW, SQLType, TIMESTAMP, TIME
15+
from trino.sqlalchemy.datatype import MAP, ROW, TIME, TIMESTAMP, SQLType
1616

1717

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

tests/unit/sqlalchemy/test_compiler.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,7 @@
1010
# See the License for the specific language governing permissions and
1111
# limitations under the License.
1212
import pytest
13-
from sqlalchemy import (
14-
Column,
15-
insert,
16-
Integer,
17-
MetaData,
18-
select,
19-
String,
20-
Table,
21-
)
13+
from sqlalchemy import Column, Integer, MetaData, String, Table, insert, select
2214
from sqlalchemy.schema import CreateTable
2315
from sqlalchemy.sql import column, table
2416

tests/unit/sqlalchemy/test_datatype_parse.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,11 @@
1111
# limitations under the License.
1212
import pytest
1313
from sqlalchemy.exc import UnsupportedCompilationError
14-
from sqlalchemy.sql.sqltypes import (
15-
CHAR,
16-
VARCHAR,
17-
ARRAY,
18-
INTEGER,
19-
DECIMAL,
20-
DATE
21-
)
14+
from sqlalchemy.sql.sqltypes import ARRAY, CHAR, DATE, DECIMAL, INTEGER, VARCHAR
2215
from sqlalchemy.sql.type_api import TypeEngine
2316

2417
from trino.sqlalchemy import datatype
25-
from trino.sqlalchemy.datatype import (
26-
MAP,
27-
ROW,
28-
TIME,
29-
TIMESTAMP
30-
)
18+
from trino.sqlalchemy.datatype import MAP, ROW, TIME, TIMESTAMP
3119

3220

3321
@pytest.mark.parametrize(

tests/unit/sqlalchemy/test_dialect.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@
22
from unittest import mock
33

44
import pytest
5-
from sqlalchemy.engine.url import make_url, URL
5+
from sqlalchemy.engine.url import URL, make_url
66

77
from trino.auth import BasicAuthentication
88
from trino.dbapi import Connection
9-
from trino.sqlalchemy.dialect import CertificateAuthentication, JWTAuthentication, TrinoDialect
10-
from trino.transaction import IsolationLevel
119
from trino.sqlalchemy import URL as trino_url
10+
from trino.sqlalchemy.dialect import (
11+
CertificateAuthentication,
12+
JWTAuthentication,
13+
TrinoDialect,
14+
)
15+
from trino.transaction import IsolationLevel
1216

1317

1418
class TestTrinoDialect:

tests/unit/test_client.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import threading
1414
import time
1515
import uuid
16-
from typing import Optional, Dict
16+
from typing import Dict, Optional
1717
from unittest import mock
1818
from urllib.parse import urlparse
1919

@@ -24,13 +24,28 @@
2424
from requests_kerberos.exceptions import KerberosExchangeError
2525

2626
import trino.exceptions
27-
from tests.unit.oauth_test_utils import RedirectHandler, GetTokenCallback, PostStatementCallback, \
28-
MultithreadedTokenServer, _post_statement_requests, _get_token_requests, REDIRECT_RESOURCE, TOKEN_RESOURCE, \
29-
SERVER_ADDRESS
27+
from tests.unit.oauth_test_utils import (
28+
REDIRECT_RESOURCE,
29+
SERVER_ADDRESS,
30+
TOKEN_RESOURCE,
31+
GetTokenCallback,
32+
MultithreadedTokenServer,
33+
PostStatementCallback,
34+
RedirectHandler,
35+
_get_token_requests,
36+
_post_statement_requests,
37+
)
3038
from trino import constants
3139
from trino.auth import KerberosAuthentication, _OAuth2TokenBearer
32-
from trino.client import TrinoQuery, TrinoRequest, TrinoResult, ClientSession, _DelayExponential, _retry_with, \
33-
_RetryWithExponentialBackoff
40+
from trino.client import (
41+
ClientSession,
42+
TrinoQuery,
43+
TrinoRequest,
44+
TrinoResult,
45+
_DelayExponential,
46+
_retry_with,
47+
_RetryWithExponentialBackoff,
48+
)
3449

3550

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

tests/unit/test_dbapi.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,16 @@
1717
from httpretty import httprettified
1818
from requests import Session
1919

20-
from tests.unit.oauth_test_utils import _post_statement_requests, _get_token_requests, RedirectHandler, \
21-
GetTokenCallback, REDIRECT_RESOURCE, TOKEN_RESOURCE, PostStatementCallback, SERVER_ADDRESS
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+
)
2230
from trino import constants
2331
from trino.auth import OAuth2Authentication
2432
from trino.dbapi import connect

tests/unit/test_http.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
# See the License for the specific language governing permissions and
1111
# limitations under the License.
1212

13-
from trino.client import get_header_values, get_session_property_values
1413
from trino import constants
14+
from trino.client import get_header_values, get_session_property_values
1515

1616

1717
def test_get_header_values():

tests/unit/test_transaction.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
# See the License for the specific language governing permissions and
1111
# limitations under the License.
1212

13-
from trino.transaction import IsolationLevel
1413
import pytest
1514

15+
from trino.transaction import IsolationLevel
16+
1617

1718
def test_isolation_level_levels() -> None:
1819
levels = {

trino/__init__.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,7 @@
1010
# See the License for the specific language governing permissions and
1111
# limitations under the License.
1212

13-
from . import auth
14-
from . import dbapi
15-
from . import client
16-
from . import constants
17-
from . import exceptions
18-
from . import logging
13+
from . import auth, client, constants, dbapi, exceptions, logging
1914

2015
__all__ = ['auth', 'dbapi', 'client', 'constants', 'exceptions', 'logging']
2116

trino/auth.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@
1111
# limitations under the License.
1212

1313
import abc
14+
import importlib
1415
import json
1516
import os
1617
import re
1718
import threading
1819
import webbrowser
19-
from typing import Optional, List, Callable
20+
from typing import Callable, List, Optional
2021
from urllib.parse import urlparse
2122

2223
from requests import Request
2324
from requests.auth import AuthBase, extract_cookies_to_jar
2425
from requests.utils import parse_dict_header
25-
import importlib
2626

2727
import trino.logging
2828
from trino.client import exceptions

trino/constants.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
from typing import Any, Optional
1414

15-
1615
DEFAULT_PORT = 8080
1716
DEFAULT_TLS_PORT = 443
1817
DEFAULT_SOURCE = "trino-python-client"

trino/dbapi.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,29 @@
1717
Fetch methods returns rows as a list of lists on purpose to let the caller
1818
decide to convert then to a list of tuples.
1919
"""
20-
from decimal import Decimal
21-
from typing import Any, List, Optional # NOQA for mypy types
22-
23-
import uuid
2420
import datetime
2521
import math
22+
import uuid
23+
from decimal import Decimal
24+
from typing import Any, List, Optional # NOQA for mypy types
2625

27-
from trino import constants
28-
import trino.exceptions
2926
import trino.client
27+
import trino.exceptions
3028
import trino.logging
31-
from trino.transaction import Transaction, IsolationLevel, NO_TRANSACTION
29+
from trino import constants
3230
from trino.exceptions import (
33-
Warning,
34-
Error,
35-
InterfaceError,
3631
DatabaseError,
3732
DataError,
38-
OperationalError,
33+
Error,
3934
IntegrityError,
35+
InterfaceError,
4036
InternalError,
41-
ProgrammingError,
4237
NotSupportedError,
38+
OperationalError,
39+
ProgrammingError,
40+
Warning,
4341
)
42+
from trino.transaction import NO_TRANSACTION, IsolationLevel, Transaction
4443

4544
__all__ = [
4645
# https://www.python.org/dev/peps/pep-0249/#globals

trino/sqlalchemy/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
# See the License for the specific language governing permissions and
1111
# limitations under the License.
1212
from sqlalchemy.dialects import registry
13+
1314
from .util import _url as URL # noqa
1415

1516
registry.register("trino", "trino.sqlalchemy.dialect", "TrinoDialect")

trino/sqlalchemy/compiler.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from sqlalchemy.sql import compiler
1313
from sqlalchemy.sql.base import DialectKWArgs
1414

15-
1615
# https://trino.io/docs/current/language/reserved.html
1716
RESERVED_WORDS = {
1817
"alter",

trino/sqlalchemy/datatype.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# limitations under the License.
1212
import json
1313
import re
14-
from typing import Iterator, List, Optional, Tuple, Type, Union, Dict, Any
14+
from typing import Any, Dict, Iterator, List, Optional, Tuple, Type, Union
1515

1616
from sqlalchemy import util
1717
from sqlalchemy.sql import sqltypes

trino/sqlalchemy/dialect.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
from sqlalchemy.engine.default import DefaultDialect, DefaultExecutionContext
2121
from sqlalchemy.engine.url import URL
2222

23-
from trino import dbapi as trino_dbapi, logging
23+
from trino import dbapi as trino_dbapi
24+
from trino import logging
2425
from trino.auth import BasicAuthentication, CertificateAuthentication, JWTAuthentication
2526
from trino.dbapi import Cursor
2627
from trino.sqlalchemy import compiler, datatype, error

trino/sqlalchemy/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import json
22
import re
3+
from typing import Dict, List, Optional, Tuple, Union
34
from urllib.parse import quote_plus
45

5-
from typing import Optional, Dict, List, Union, Tuple
66
from sqlalchemy import exc
77

88

trino/transaction.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@
1212
from enum import Enum, unique
1313
from typing import Iterable
1414

15-
from trino import constants
1615
import trino.client
1716
import trino.exceptions
1817
import trino.logging
19-
18+
from trino import constants
2019

2120
logger = trino.logging.get_logger(__name__)
2221

0 commit comments

Comments
 (0)