Skip to content

Commit

Permalink
Add isort
Browse files Browse the repository at this point in the history
  • Loading branch information
LuckySting committed Jan 25, 2024
1 parent 0e6d604 commit 389acc7
Show file tree
Hide file tree
Showing 16 changed files with 124 additions and 87 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ $ tox -e style

Reformat code:
```bash
$ tox -e isort
$ tox -e black-format
```

Expand Down
7 changes: 3 additions & 4 deletions examples/example.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import datetime
import logging
import sqlalchemy as sa
from sqlalchemy import orm, exc, sql
from sqlalchemy import Table, Column, Integer, String, Float, TIMESTAMP

import sqlalchemy as sa
from fill_tables import fill_all_tables, to_days
from models import Base, Series, Episodes
from models import Base, Episodes, Series
from sqlalchemy import TIMESTAMP, Column, Float, Integer, String, Table, exc, orm, sql


def describe_table(engine, name):
Expand Down
3 changes: 1 addition & 2 deletions examples/fill_tables.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import iso8601

import sqlalchemy as sa
from models import Base, Series, Seasons, Episodes
from models import Base, Episodes, Seasons, Series


def to_days(date):
Expand Down
1 change: 0 additions & 1 deletion examples/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import sqlalchemy.orm as orm
from sqlalchemy import Column, Integer, Unicode


Base = orm.declarative_base()


Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
[tool.black]
line-length = 120

[tool.isort]
profile = "black"
1 change: 1 addition & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ flake8==3.9.2
black==23.3.0
pytest-cov
pytest-asyncio
isort==5.13.2
10 changes: 4 additions & 6 deletions test/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@
from typing import NamedTuple

import pytest

import sqlalchemy as sa
from sqlalchemy import Table, Column, Integer, Unicode, String
from sqlalchemy.testing.fixtures import TestBase, TablesTest, config

import ydb
from sqlalchemy import Column, Integer, String, Table, Unicode
from sqlalchemy.testing.fixtures import TablesTest, TestBase, config
from ydb._grpc.v4.protos import ydb_common_pb2

from ydb_sqlalchemy import dbapi, IsolationLevel
from ydb_sqlalchemy.sqlalchemy import types
from ydb_sqlalchemy import IsolationLevel, dbapi
from ydb_sqlalchemy import sqlalchemy as ydb_sa
from ydb_sqlalchemy.sqlalchemy import types


def clear_sql(stm):
Expand Down
3 changes: 1 addition & 2 deletions test/test_inspect.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import sqlalchemy as sa

from sqlalchemy import Table, Column, Integer, Unicode, Numeric
from sqlalchemy import Column, Integer, Numeric, Table, Unicode
from sqlalchemy.testing.fixtures import TablesTest


Expand Down
103 changes: 67 additions & 36 deletions test/test_suite.py
Original file line number Diff line number Diff line change
@@ -1,55 +1,86 @@
import pytest
import sqlalchemy as sa
import sqlalchemy.testing.suite.test_types

from sqlalchemy.testing import is_false, is_true
from sqlalchemy.testing.suite import * # noqa: F401, F403

from sqlalchemy.testing import is_true, is_false
from sqlalchemy.testing.suite import eq_, testing, inspect, provide_metadata, config, requirements, fixtures
from sqlalchemy.testing.suite import func, column, literal_column, select, exists
from sqlalchemy.testing.suite import MetaData, Column, Table, Integer, String

from sqlalchemy.testing.suite.test_select import (
ExistsTest as _ExistsTest,
LikeFunctionsTest as _LikeFunctionsTest,
CompoundSelectTest as _CompoundSelectTest,
from sqlalchemy.testing.suite import (
Column,
Integer,
MetaData,
String,
Table,
column,
config,
eq_,
exists,
fixtures,
func,
inspect,
literal_column,
provide_metadata,
requirements,
select,
testing,
)
from sqlalchemy.testing.suite.test_ddl import (
LongNameBlowoutTest as _LongNameBlowoutTest,
)
from sqlalchemy.testing.suite.test_deprecations import (
DeprecatedCompoundSelectTest as _DeprecatedCompoundSelectTest,
)
from sqlalchemy.testing.suite.test_dialect import (
DifficultParametersTest as _DifficultParametersTest,
)
from sqlalchemy.testing.suite.test_dialect import EscapingTest as _EscapingTest
from sqlalchemy.testing.suite.test_insert import (
InsertBehaviorTest as _InsertBehaviorTest,
)
from sqlalchemy.testing.suite.test_reflection import (
HasTableTest as _HasTableTest,
HasIndexTest as _HasIndexTest,
ComponentReflectionTest as _ComponentReflectionTest,
CompositeKeyReflectionTest as _CompositeKeyReflectionTest,
)
from sqlalchemy.testing.suite.test_reflection import (
ComponentReflectionTestExtra as _ComponentReflectionTestExtra,
)
from sqlalchemy.testing.suite.test_reflection import (
CompositeKeyReflectionTest as _CompositeKeyReflectionTest,
)
from sqlalchemy.testing.suite.test_reflection import HasIndexTest as _HasIndexTest
from sqlalchemy.testing.suite.test_reflection import HasTableTest as _HasTableTest
from sqlalchemy.testing.suite.test_reflection import (
QuotedNameArgumentTest as _QuotedNameArgumentTest,
)
from sqlalchemy.testing.suite.test_results import RowFetchTest as _RowFetchTest
from sqlalchemy.testing.suite.test_select import (
CompoundSelectTest as _CompoundSelectTest,
)
from sqlalchemy.testing.suite.test_select import ExistsTest as _ExistsTest
from sqlalchemy.testing.suite.test_select import (
FetchLimitOffsetTest as _FetchLimitOffsetTest,
)
from sqlalchemy.testing.suite.test_select import JoinTest as _JoinTest
from sqlalchemy.testing.suite.test_select import LikeFunctionsTest as _LikeFunctionsTest
from sqlalchemy.testing.suite.test_select import OrderByLabelTest as _OrderByLabelTest
from sqlalchemy.testing.suite.test_types import BinaryTest as _BinaryTest
from sqlalchemy.testing.suite.test_types import DateTest as _DateTest
from sqlalchemy.testing.suite.test_types import (
IntegerTest as _IntegerTest,
NumericTest as _NumericTest,
BinaryTest as _BinaryTest,
TrueDivTest as _TrueDivTest,
TimeTest as _TimeTest,
StringTest as _StringTest,
NativeUUIDTest as _NativeUUIDTest,
TimeMicrosecondsTest as _TimeMicrosecondsTest,
DateTimeCoercedToDateTimeTest as _DateTimeCoercedToDateTimeTest,
DateTest as _DateTest,
)
from sqlalchemy.testing.suite.test_types import (
DateTimeMicrosecondsTest as _DateTimeMicrosecondsTest,
DateTimeTest as _DateTimeTest,
TimestampMicrosecondsTest as _TimestampMicrosecondsTest,
)
from sqlalchemy.testing.suite.test_dialect import (
EscapingTest as _EscapingTest,
DifficultParametersTest as _DifficultParametersTest,
from sqlalchemy.testing.suite.test_types import DateTimeTest as _DateTimeTest
from sqlalchemy.testing.suite.test_types import IntegerTest as _IntegerTest
from sqlalchemy.testing.suite.test_types import NativeUUIDTest as _NativeUUIDTest
from sqlalchemy.testing.suite.test_types import NumericTest as _NumericTest
from sqlalchemy.testing.suite.test_types import StringTest as _StringTest
from sqlalchemy.testing.suite.test_types import (
TimeMicrosecondsTest as _TimeMicrosecondsTest,
)
from sqlalchemy.testing.suite.test_select import (
JoinTest as _JoinTest,
OrderByLabelTest as _OrderByLabelTest,
FetchLimitOffsetTest as _FetchLimitOffsetTest,
from sqlalchemy.testing.suite.test_types import (
TimestampMicrosecondsTest as _TimestampMicrosecondsTest,
)
from sqlalchemy.testing.suite.test_insert import InsertBehaviorTest as _InsertBehaviorTest
from sqlalchemy.testing.suite.test_ddl import LongNameBlowoutTest as _LongNameBlowoutTest
from sqlalchemy.testing.suite.test_results import RowFetchTest as _RowFetchTest
from sqlalchemy.testing.suite.test_deprecations import DeprecatedCompoundSelectTest as _DeprecatedCompoundSelectTest
from sqlalchemy.testing.suite.test_types import TimeTest as _TimeTest
from sqlalchemy.testing.suite.test_types import TrueDivTest as _TrueDivTest

from ydb_sqlalchemy.sqlalchemy import types as ydb_sa_types

Expand Down
8 changes: 4 additions & 4 deletions test_dbapi/test_dbapi.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from contextlib import suppress

import pytest
import pytest_asyncio

import sqlalchemy.util as util
import ydb
import ydb_sqlalchemy.dbapi as dbapi

from contextlib import suppress
import sqlalchemy.util as util
import ydb_sqlalchemy.dbapi as dbapi


class BaseDBApiTestSuit:
Expand Down
5 changes: 5 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ skip_install = true
commands =
black ydb_sqlalchemy examples test test_dbapi

[testenv:isort]
skip_install = true
commands =
isort ydb_sqlalchemy examples test test_dbapi

[testenv:style]
ignore_errors = True
commands =
Expand Down
14 changes: 7 additions & 7 deletions ydb_sqlalchemy/dbapi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
from .connection import Connection, AsyncConnection, IsolationLevel # noqa: F401
from .cursor import Cursor, AsyncCursor, YdbQuery # noqa: F401
from .connection import AsyncConnection, Connection, IsolationLevel # noqa: F401
from .cursor import AsyncCursor, Cursor, YdbQuery # noqa: F401
from .errors import (
Warning,
Error,
InterfaceError,
DatabaseError,
DataError,
OperationalError,
Error,
IntegrityError,
InterfaceError,
InternalError,
ProgrammingError,
NotSupportedError,
OperationalError,
ProgrammingError,
Warning,
)


Expand Down
9 changes: 5 additions & 4 deletions ydb_sqlalchemy/dbapi/connection.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import collections.abc
import posixpath
from typing import Optional, NamedTuple, Any, List
from typing import Any, List, NamedTuple, Optional

import ydb
import sqlalchemy.util as util
import collections.abc
from .cursor import Cursor, AsyncCursor
import ydb

from .cursor import AsyncCursor, Cursor
from .errors import InterfaceError, InternalError, NotSupportedError


Expand Down
18 changes: 9 additions & 9 deletions ydb_sqlalchemy/dbapi/cursor.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import collections.abc
import dataclasses
import functools
import itertools
import logging
import functools
from typing import Any, Mapping, Optional, Sequence, Union, Dict, List
import collections.abc
from sqlalchemy import util
from typing import Any, Dict, List, Mapping, Optional, Sequence, Union

import ydb
import ydb.aio
from sqlalchemy import util

from .errors import (
InternalError,
IntegrityError,
DataError,
DatabaseError,
ProgrammingError,
OperationalError,
DataError,
IntegrityError,
InternalError,
NotSupportedError,
OperationalError,
ProgrammingError,
)

logger = logging.getLogger(__name__)
Expand Down
20 changes: 10 additions & 10 deletions ydb_sqlalchemy/sqlalchemy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@
"""
import collections
import collections.abc
import ydb
import ydb_sqlalchemy.dbapi as dbapi
from ydb_sqlalchemy.dbapi.constants import YDB_KEYWORDS
from ydb_sqlalchemy.sqlalchemy.dml import Upsert
from typing import Any, Dict, List, Mapping, Optional, Sequence, Tuple, Union

import sqlalchemy as sa
import ydb
from sqlalchemy.engine import reflection
from sqlalchemy.engine.default import DefaultExecutionContext, StrCompileDialect
from sqlalchemy.exc import CompileError, NoSuchTableError
from sqlalchemy.sql import functions, literal_column
from sqlalchemy.sql.compiler import (
selectable,
DDLCompiler,
IdentifierPreparer,
StrSQLTypeCompiler,
StrSQLCompiler,
DDLCompiler,
StrSQLTypeCompiler,
selectable,
)
from sqlalchemy.sql.elements import ClauseList
from sqlalchemy.engine import reflection
from sqlalchemy.engine.default import StrCompileDialect, DefaultExecutionContext
from sqlalchemy.util.compat import inspect_getfullargspec

from typing import Any, Union, Mapping, Sequence, Optional, Tuple, List, Dict
import ydb_sqlalchemy.dbapi as dbapi
from ydb_sqlalchemy.dbapi.constants import YDB_KEYWORDS
from ydb_sqlalchemy.sqlalchemy.dml import Upsert

from . import types

Expand Down
5 changes: 3 additions & 2 deletions ydb_sqlalchemy/sqlalchemy/types.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from sqlalchemy import exc, ColumnElement, ARRAY, types
from typing import Any, Mapping, Type, Union

from sqlalchemy import ARRAY, ColumnElement, exc, types
from sqlalchemy.sql import type_api
from typing import Mapping, Any, Union, Type


class UInt32(types.Integer):
Expand Down

0 comments on commit 389acc7

Please sign in to comment.