Skip to content

Commit 7f5ac49

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent d7447cc commit 7f5ac49

File tree

7 files changed

+25
-25
lines changed

7 files changed

+25
-25
lines changed

src/graphql_sqlalchemy/graphql_types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def _get_array_item_type(column_type: TypeEngine[Any]) -> TypeEngine[Any] | None
109109
and hasattr(column_type, "item_type")
110110
):
111111
return None
112-
return cast(TypeEngine[Any], column_type.item_type)
112+
return cast("TypeEngine[Any]", column_type.item_type)
113113

114114

115115
def get_graphql_type_from_column(
@@ -139,7 +139,7 @@ def get_graphql_type_from_column(
139139

140140

141141
def get_base_comparison_fields(
142-
graphql_type: GraphQLScalarType | GraphQLEnumType | GraphQLList[Any]
142+
graphql_type: GraphQLScalarType | GraphQLEnumType | GraphQLList[Any],
143143
) -> dict[str, GraphQLInputField]:
144144
return {
145145
"_eq": GraphQLInputField(graphql_type),

src/graphql_sqlalchemy/resolvers.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ def all_scalars(
4848
selection: W,
4949
*,
5050
execution_options: OrmExecuteOptionsParameter = MappingProxyType({}),
51-
) -> Sequence[DeclarativeBase]:
52-
...
51+
) -> Sequence[DeclarativeBase]: ...
5352

5453

5554
@overload
@@ -58,8 +57,7 @@ def all_scalars(
5857
selection: W,
5958
*,
6059
execution_options: OrmExecuteOptionsParameter = MappingProxyType({}),
61-
) -> Awaitable[Sequence[DeclarativeBase]]:
62-
...
60+
) -> Awaitable[Sequence[DeclarativeBase]]: ...
6361

6462

6563
def all_scalars(
@@ -242,7 +240,7 @@ def resolver(
242240
offset: int | None = None,
243241
) -> AwaitableOrValue[Sequence[DeclarativeBase]]:
244242
if all(f is None for f in [where, order, limit, offset]):
245-
return cast(Sequence[Any], getattr(root, field_name))
243+
return cast("Sequence[Any]", getattr(root, field_name))
246244
session = info.context["session"]
247245
relationship: InstrumentedAttribute[Any] = getattr(root.__class__, field_name)
248246
field_model = relationship.prop.entity.class_
@@ -281,15 +279,13 @@ def resolver(_root: None, info: ResolveInfo, **kwargs: dict[str, Any]) -> Awaita
281279
@overload
282280
def session_add_object(
283281
obj: dict[str, Any], model: type[DeclarativeBase], session: Session, *, on_conflict: dict[str, Any] | None
284-
) -> DeclarativeBase:
285-
...
282+
) -> DeclarativeBase: ...
286283

287284

288285
@overload
289286
def session_add_object(
290287
obj: dict[str, Any], model: type[DeclarativeBase], session: AsyncSession, *, on_conflict: dict[str, Any] | None
291-
) -> Awaitable[DeclarativeBase]:
292-
...
288+
) -> Awaitable[DeclarativeBase]: ...
293289

294290

295291
def session_add_object(

tests/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
],
2727
)
2828
def is_async(request: pytest.FixtureRequest) -> bool:
29-
return cast(bool, request.param)
29+
return cast("bool", request.param)
3030

3131

3232
@pytest.fixture(scope="session")
@@ -52,7 +52,7 @@ def db_session_factory(db_engine: Engine | AsyncEngine) -> scoped_session[Sessio
5252
return scoped_session(sessionmaker(bind=db_engine))
5353

5454

55-
@pytest.fixture()
55+
@pytest.fixture
5656
async def db_session(
5757
db_session_factory: scoped_session[Session] | async_scoped_session[AsyncSession],
5858
) -> AsyncGenerator[Session | AsyncSession, None]:

tests/test_build_schema.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@
1515
GraphQLScalarType,
1616
GraphQLString,
1717
)
18-
from graphql_sqlalchemy import build_schema
19-
from graphql_sqlalchemy.testing import JsonArray, assert_equal_gql_type
2018
from sqlalchemy import Column, ForeignKey, Integer, Table
2119
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column, registry, relationship
2220

21+
from graphql_sqlalchemy import build_schema
22+
from graphql_sqlalchemy.testing import JsonArray, assert_equal_gql_type
23+
2324
# Tested types
2425

2526

@@ -77,15 +78,15 @@ class Project(Base):
7778
)
7879
def test_build_schema_simple(field: str, gql_type: GraphQLScalarType) -> None:
7980
schema = build_schema(Base)
80-
user = cast(Union[GraphQLObjectType, None], schema.get_type("user"))
81+
user = cast("Union[GraphQLObjectType, None]", schema.get_type("user"))
8182
assert user
8283
f: GraphQLField = user.fields[field]
8384
assert_equal_gql_type(f.type, GraphQLNonNull(gql_type))
8485

8586

8687
def test_build_schema_rel() -> None:
8788
schema = build_schema(Base)
88-
user = cast(Union[GraphQLObjectType, None], schema.get_type("user"))
89+
user = cast("Union[GraphQLObjectType, None]", schema.get_type("user"))
8990
assert user
9091
f: GraphQLField = user.fields["projects"]
9192
assert isinstance(f.type, GraphQLNonNull)

tests/test_graphql/conftest.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@
88

99
import pytest
1010
from graphql import ExecutionResult, GraphQLSchema, graphql, graphql_sync
11-
from graphql_sqlalchemy.schema import build_schema
12-
from graphql_sqlalchemy.testing import JsonArray
1311
from sqlalchemy import Column, Engine, ForeignKey, String, Table
1412
from sqlalchemy.ext.asyncio import AsyncEngine, AsyncSession
1513
from sqlalchemy.ext.hybrid import hybrid_property
1614
from sqlalchemy.orm import DeclarativeBase, Mapped, Session, mapped_column, registry, relationship
1715

16+
from graphql_sqlalchemy.schema import build_schema
17+
from graphql_sqlalchemy.testing import JsonArray
18+
1819
if TYPE_CHECKING:
1920
from collections.abc import AsyncGenerator, Callable
2021

@@ -96,7 +97,7 @@ def gql_schema() -> GraphQLSchema:
9697
return build_schema(Base)
9798

9899

99-
@pytest.fixture()
100+
@pytest.fixture
100101
async def example_session(
101102
db_engine: Engine | AsyncEngine, db_session: Session | AsyncSession
102103
) -> AsyncGenerator[Session | AsyncSession, None]:
@@ -129,7 +130,7 @@ def raise_if_errors(result: ExecutionResult) -> None:
129130
raise result.errors[0] if len(result.errors) == 1 else ExceptionGroup("Invalid Query", result.errors)
130131

131132

132-
@pytest.fixture()
133+
@pytest.fixture
133134
def graphql_example(
134135
example_session: Session | AsyncSession, gql_schema: GraphQLSchema
135136
) -> Callable[[str], dict[str, Any]]:
@@ -155,15 +156,15 @@ async def gql_async(session: AsyncSession) -> ExecutionResult:
155156
return graphql_
156157

157158

158-
@pytest.fixture()
159+
@pytest.fixture
159160
def query_example(graphql_example: Callable[[str], dict[str, Any]]) -> Callable[[str], dict[str, Any]]:
160161
def query(source: str) -> dict[str, Any]:
161162
return graphql_example(f"query {{\n{indent(source, ' ')}\n}}")
162163

163164
return query
164165

165166

166-
@pytest.fixture()
167+
@pytest.fixture
167168
def mutation_example(graphql_example: Callable[[str], dict[str, Any]]) -> Callable[[str], dict[str, Any]]:
168169
def mutation(source: str) -> dict[str, Any]:
169170
return graphql_example(f"mutation {{\n{indent(source, ' ')}\n}}")

tests/test_types.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@
1616
GraphQLScalarType,
1717
GraphQLString,
1818
)
19-
from graphql_sqlalchemy.graphql_types import get_graphql_type_from_column, get_graphql_type_from_python
20-
from graphql_sqlalchemy.testing import assert_equal_gql_type
2119
from sqlalchemy import ARRAY, Boolean, Column, Float, Integer, String
2220
from sqlalchemy import Enum as SqlaEnum
2321

22+
from graphql_sqlalchemy.graphql_types import get_graphql_type_from_column, get_graphql_type_from_python
23+
from graphql_sqlalchemy.testing import assert_equal_gql_type
24+
2425
if sys.version_info >= (3, 10):
2526
str_or_none = str | None
2627
else:

tests/test_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import pytest
44
from graphql import GraphQLInt, GraphQLString
5+
56
from graphql_sqlalchemy.testing import assert_equal_gql_type
67

78

0 commit comments

Comments
 (0)