Skip to content

Commit 67a621f

Browse files
committed
2 parents faadf03 + 1033de5 commit 67a621f

15 files changed

+31
-33
lines changed

.pre-commit-config.yaml

+8-9
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@ repos:
77
- id: check-merge-conflict
88
- id: check-yaml
99
- id: debug-statements
10-
# TDOO Enable in separate PR
11-
# - id: end-of-file-fixer
12-
# exclude: ^docs/.*$
13-
# - id: trailing-whitespace
14-
# exclude: README.md
15-
# - repo: git://github.com/PyCQA/flake8
16-
# rev: 88caf5ac484f5c09aedc02167c59c66ff0af0068 # 3.7.7
17-
# hooks:
18-
# - id: flake8
10+
- id: end-of-file-fixer
11+
exclude: ^docs/.*$
12+
- id: trailing-whitespace
13+
exclude: README.md
14+
- repo: git://github.com/PyCQA/flake8
15+
rev: 88caf5ac484f5c09aedc02167c59c66ff0af0068 # 3.7.7
16+
hooks:
17+
- id: flake8

docs/examples.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ Search all Models with Union
3737
class Query(graphene.ObjectType):
3838
node = relay.Node.Field()
3939
search = graphene.List(SearchResult, q=graphene.String()) # List field for search results
40-
40+
4141
# Normal Fields
4242
all_books = SQLAlchemyConnectionField(BookConnection)
4343
all_authors = SQLAlchemyConnectionField(AuthorConnection)
4444
4545
def resolve_search(self, info, **args):
4646
q = args.get("q") # Search query
47-
47+
4848
# Get queries
4949
bookdata_query = BookData.get_query(info)
5050
author_query = Author.get_query(info)
@@ -53,14 +53,14 @@ Search all Models with Union
5353
books = bookdata_query.filter((BookModel.title.contains(q)) |
5454
(BookModel.isbn.contains(q)) |
5555
(BookModel.authors.any(AuthorModel.name.contains(q)))).all()
56-
56+
5757
# Query Authors
5858
authors = author_query.filter(AuthorModel.name.contains(q)).all()
5959
6060
return authors + books # Combine lists
6161
6262
schema = graphene.Schema(query=Query, types=[Book, Author, SearchResult])
63-
63+
6464
Example GraphQL query
6565

6666
.. code::

docs/tips.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ If you don't specify any, the following error will be displayed:
3131
Sorting
3232
-------
3333

34-
By default the SQLAlchemyConnectionField sorts the result elements over the primary key(s).
34+
By default the SQLAlchemyConnectionField sorts the result elements over the primary key(s).
3535
The query has a `sort` argument which allows to sort over a different column(s)
3636

3737
Given the model

examples/nameko_sqlalchemy/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,4 @@ Now the following command will setup the database, and start the server:
5151

5252
Now head on over to postman and send POST request to:
5353
[http://127.0.0.1:5000/graphql](http://127.0.0.1:5000/graphql)
54-
and run some queries!
54+
and run some queries!

examples/nameko_sqlalchemy/app.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def query(self, request):
1919
execution_results,
2020
format_error=default_format_error,is_batch=False, encode=json_encode)
2121
return result
22-
22+
2323
def parse_body(self,request):
2424
# We use mimetype here since we don't need the other
2525
# information provided by content_type
@@ -33,4 +33,4 @@ def parse_body(self,request):
3333
elif content_type in ('application/x-www-form-urlencoded', 'multipart/form-data'):
3434
return request.form
3535

36-
return {}
36+
return {}

examples/nameko_sqlalchemy/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
WEB_SERVER_ADDRESS: '0.0.0.0:5000'
1+
WEB_SERVER_ADDRESS: '0.0.0.0:5000'
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
graphene[sqlalchemy]
22
SQLAlchemy==1.0.11
33
nameko
4-
graphql-server-core
4+
graphql-server-core

examples/nameko_sqlalchemy/run.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/sh
22
echo "Starting application service server"
33
# Run Service
4-
nameko run --config config.yml service
4+
nameko run --config config.yml service

examples/nameko_sqlalchemy/service.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#!/usr/bin/env python
22
from nameko.web.handlers import http
3-
from app import App
3+
from app import App
44

55

66
class DepartmentService:
7-
name = 'department'
7+
name = 'department'
88

99
@http('POST', '/graphql')
1010
def query(self, request):
11-
return App().query(request)
11+
return App().query(request)

graphene_sqlalchemy/tests/test_converter.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ class Test(Base):
168168
)
169169

170170
graphene_type = convert_sqlalchemy_column(Test.column)
171-
assert graphene_type.kwargs["required"] == False
171+
assert not graphene_type.kwargs["required"]
172172

173173

174174
def test_should_scalar_list_convert_list():
@@ -343,4 +343,3 @@ def __init__(self, col1, col2):
343343
)
344344

345345
assert "Don't know how to convert the composite field" in str(excinfo.value)
346-

graphene_sqlalchemy/tests/test_query.py

-1
Original file line numberDiff line numberDiff line change
@@ -555,4 +555,3 @@ def makeNodes(nodeList):
555555
assert set(node["node"]["name"] for node in value["edges"]) == set(
556556
node["node"]["name"] for node in expectedNoSort[key]["edges"]
557557
)
558-

graphene_sqlalchemy/tests/test_reflected.py

-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,3 @@ def test_objecttype_registered():
1818
assert issubclass(Reflected, ObjectType)
1919
assert Reflected._meta.model == ReflectedEditor
2020
assert list(Reflected._meta.fields.keys()) == ["editor_id", "name"]
21-

graphene_sqlalchemy/tests/test_schema.py

-1
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,3 @@ class Meta:
4747
model = Reporter
4848
only_fields = ("id", "email")
4949
assert list(Reporter2._meta.fields.keys()) == ["id", "email"]
50-

graphene_sqlalchemy/tests/test_types.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from collections import OrderedDict
22
from graphene import Field, Int, Interface, ObjectType
33
from graphene.relay import Node, is_node, Connection
4-
import six
4+
import six # noqa F401
55
from promise import Promise
66

77
from ..registry import Registry
@@ -176,7 +176,9 @@ class TestConnection(Connection):
176176
class Meta:
177177
node = ReporterWithCustomOptions
178178

179-
resolver = lambda *args, **kwargs: Promise.resolve([])
179+
def resolver(*args, **kwargs):
180+
return Promise.resolve([])
181+
180182
result = SQLAlchemyConnectionField.connection_resolver(
181183
resolver, TestConnection, ReporterWithCustomOptions, None, None
182184
)

graphene_sqlalchemy/types.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from collections import OrderedDict
22

3+
import sqlalchemy
34
from sqlalchemy.inspection import inspect as sqlalchemyinspect
45
from sqlalchemy.ext.hybrid import hybrid_property
56
from sqlalchemy.orm.exc import NoResultFound
@@ -80,9 +81,9 @@ def construct_fields(model, registry, only_fields, exclude_fields):
8081

8182

8283
class SQLAlchemyObjectTypeOptions(ObjectTypeOptions):
83-
model = None # type: Model
84-
registry = None # type: Registry
85-
connection = None # type: Type[Connection]
84+
model = None # type: sqlalchemy.Model
85+
registry = None # type: sqlalchemy.Registry
86+
connection = None # type: sqlalchemy.Type[sqlalchemy.Connection]
8687
id = None # type: str
8788

8889

0 commit comments

Comments
 (0)