Skip to content

Re-enable linters as pre-commit hooks #191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ repos:
- id: check-merge-conflict
- id: check-yaml
- id: debug-statements
# TDOO Enable in separate PR
# - id: end-of-file-fixer
# exclude: ^docs/.*$
# - id: trailing-whitespace
# exclude: README.md
# - repo: git://github.com/PyCQA/flake8
# rev: 88caf5ac484f5c09aedc02167c59c66ff0af0068 # 3.7.7
# hooks:
# - id: flake8
- id: end-of-file-fixer
exclude: ^docs/.*$
- id: trailing-whitespace
exclude: README.md
- repo: git://github.com/PyCQA/flake8
rev: 88caf5ac484f5c09aedc02167c59c66ff0af0068 # 3.7.7
hooks:
- id: flake8
8 changes: 4 additions & 4 deletions docs/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ Search all Models with Union
class Query(graphene.ObjectType):
node = relay.Node.Field()
search = graphene.List(SearchResult, q=graphene.String()) # List field for search results

# Normal Fields
all_books = SQLAlchemyConnectionField(BookConnection)
all_authors = SQLAlchemyConnectionField(AuthorConnection)

def resolve_search(self, info, **args):
q = args.get("q") # Search query

# Get queries
bookdata_query = BookData.get_query(info)
author_query = Author.get_query(info)
Expand All @@ -53,14 +53,14 @@ Search all Models with Union
books = bookdata_query.filter((BookModel.title.contains(q)) |
(BookModel.isbn.contains(q)) |
(BookModel.authors.any(AuthorModel.name.contains(q)))).all()

# Query Authors
authors = author_query.filter(AuthorModel.name.contains(q)).all()

return authors + books # Combine lists

schema = graphene.Schema(query=Query, types=[Book, Author, SearchResult])

Example GraphQL query

.. code::
Expand Down
2 changes: 1 addition & 1 deletion docs/tips.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ If you don't specify any, the following error will be displayed:
Sorting
-------

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

Given the model
Expand Down
2 changes: 1 addition & 1 deletion examples/nameko_sqlalchemy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ Now the following command will setup the database, and start the server:

Now head on over to postman and send POST request to:
[http://127.0.0.1:5000/graphql](http://127.0.0.1:5000/graphql)
and run some queries!
and run some queries!
4 changes: 2 additions & 2 deletions examples/nameko_sqlalchemy/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def query(self, request):
execution_results,
format_error=default_format_error,is_batch=False, encode=json_encode)
return result

def parse_body(self,request):
# We use mimetype here since we don't need the other
# information provided by content_type
Expand All @@ -33,4 +33,4 @@ def parse_body(self,request):
elif content_type in ('application/x-www-form-urlencoded', 'multipart/form-data'):
return request.form

return {}
return {}
2 changes: 1 addition & 1 deletion examples/nameko_sqlalchemy/config.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
WEB_SERVER_ADDRESS: '0.0.0.0:5000'
WEB_SERVER_ADDRESS: '0.0.0.0:5000'
2 changes: 1 addition & 1 deletion examples/nameko_sqlalchemy/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
graphene[sqlalchemy]
SQLAlchemy==1.0.11
nameko
graphql-server-core
graphql-server-core
2 changes: 1 addition & 1 deletion examples/nameko_sqlalchemy/run.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
echo "Starting application service server"
# Run Service
nameko run --config config.yml service
nameko run --config config.yml service
6 changes: 3 additions & 3 deletions examples/nameko_sqlalchemy/service.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/usr/bin/env python
from nameko.web.handlers import http
from app import App
from app import App


class DepartmentService:
name = 'department'
name = 'department'

@http('POST', '/graphql')
def query(self, request):
return App().query(request)
return App().query(request)
3 changes: 1 addition & 2 deletions graphene_sqlalchemy/tests/test_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ class Test(Base):
)

graphene_type = convert_sqlalchemy_column(Test.column)
assert graphene_type.kwargs["required"] == False
assert not graphene_type.kwargs["required"]


def test_should_scalar_list_convert_list():
Expand Down Expand Up @@ -343,4 +343,3 @@ def __init__(self, col1, col2):
)

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

1 change: 0 additions & 1 deletion graphene_sqlalchemy/tests/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,4 +555,3 @@ def makeNodes(nodeList):
assert set(node["node"]["name"] for node in value["edges"]) == set(
node["node"]["name"] for node in expectedNoSort[key]["edges"]
)

1 change: 0 additions & 1 deletion graphene_sqlalchemy/tests/test_reflected.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,3 @@ def test_objecttype_registered():
assert issubclass(Reflected, ObjectType)
assert Reflected._meta.model == ReflectedEditor
assert list(Reflected._meta.fields.keys()) == ["editor_id", "name"]

1 change: 0 additions & 1 deletion graphene_sqlalchemy/tests/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,3 @@ class Meta:
model = Reporter
only_fields = ("id", "email")
assert list(Reporter2._meta.fields.keys()) == ["id", "email"]

6 changes: 4 additions & 2 deletions graphene_sqlalchemy/tests/test_types.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from collections import OrderedDict
from graphene import Field, Int, Interface, ObjectType
from graphene.relay import Node, is_node, Connection
import six
import six # noqa F401
from promise import Promise

from ..registry import Registry
Expand Down Expand Up @@ -176,7 +176,9 @@ class TestConnection(Connection):
class Meta:
node = ReporterWithCustomOptions

resolver = lambda *args, **kwargs: Promise.resolve([])
def resolver(*args, **kwargs):
return Promise.resolve([])

result = SQLAlchemyConnectionField.connection_resolver(
resolver, TestConnection, ReporterWithCustomOptions, None, None
)
Expand Down
7 changes: 4 additions & 3 deletions graphene_sqlalchemy/types.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from collections import OrderedDict

import sqlalchemy
from sqlalchemy.inspection import inspect as sqlalchemyinspect
from sqlalchemy.ext.hybrid import hybrid_property
from sqlalchemy.orm.exc import NoResultFound
Expand Down Expand Up @@ -80,9 +81,9 @@ def construct_fields(model, registry, only_fields, exclude_fields):


class SQLAlchemyObjectTypeOptions(ObjectTypeOptions):
model = None # type: Model
registry = None # type: Registry
connection = None # type: Type[Connection]
model = None # type: sqlalchemy.Model
registry = None # type: sqlalchemy.Registry
connection = None # type: sqlalchemy.Type[sqlalchemy.Connection]
id = None # type: str


Expand Down