Skip to content

Commit d46e957

Browse files
committed
Improved syntax. Added autolinter. Added automatic flake8 checker in tests. Fixed #17
1 parent 9ea57ec commit d46e957

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+251
-334
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ install:
1313
- python setup.py develop
1414
script:
1515
- py.test --cov=graphene
16-
# - flake8
16+
- flake8
1717
after_success:
1818
- coveralls

bin/autolinter

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
autoflake ./ -r --remove-unused-variables --remove-all-unused-imports --in-place
4+
isort -rc .

examples/starwars/schema.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
from graphql.core.type import GraphQLEnumValue
21
import graphene
32
from graphene import resolve_only_args
3+
from graphql.core.type import GraphQLEnumValue
44

5-
from .data import getHero, getHuman, getCharacter, getDroid
5+
from .data import getCharacter, getDroid, getHero, getHuman
66

77
Episode = graphene.Enum('Episode', dict(
88
NEWHOPE=GraphQLEnumValue(4),

examples/starwars/tests/test_query.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
from ..schema import Schema, Query
2-
from graphql.core import graphql
1+
32
from ..data import setup
3+
from ..schema import Schema
44

55
setup()
66

7+
78
def test_hero_name_query():
89
query = '''
910
query HeroNameQuery {

examples/starwars_django/data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from .models import Ship, Faction, Character
1+
from .models import Character, Faction, Ship
22

33

44
def initialize():

examples/starwars_django/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from __future__ import absolute_import
2+
23
from django.db import models
34

45

examples/starwars_django/schema.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,18 @@
11
import graphene
2-
from graphene import resolve_only_args, relay
3-
from graphene.contrib.django import (
4-
DjangoObjectType,
5-
DjangoNode
6-
)
7-
from .models import (
8-
Ship as ShipModel, Faction as FactionModel, Character as CharacterModel)
9-
from .data import (
10-
get_faction,
11-
get_ship,
12-
get_ships,
13-
get_rebels,
14-
get_empire,
15-
create_ship
16-
)
2+
from graphene import relay, resolve_only_args
3+
from graphene.contrib.django import DjangoNode, DjangoObjectType
4+
5+
from .data import (create_ship, get_empire, get_faction, get_rebels, get_ship,
6+
get_ships)
7+
from .models import Character as CharacterModel
8+
from .models import Faction as FactionModel
9+
from .models import Ship as ShipModel
1710

1811
schema = graphene.Schema(name='Starwars Django Relay Schema')
1912

2013

2114
class Ship(DjangoNode):
15+
2216
class Meta:
2317
model = ShipModel
2418

@@ -29,11 +23,13 @@ def get_node(cls, id):
2923

3024
@schema.register
3125
class Character(DjangoObjectType):
26+
3227
class Meta:
3328
model = CharacterModel
3429

3530

3631
class Faction(DjangoNode):
32+
3733
class Meta:
3834
model = FactionModel
3935

@@ -43,6 +39,7 @@ def get_node(cls, id):
4339

4440

4541
class IntroduceShip(relay.ClientIDMutation):
42+
4643
class Input:
4744
ship_name = graphene.StringField(required=True)
4845
faction_id = graphene.StringField(required=True)

examples/starwars_django/tests/test_connections.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import pytest
2-
from graphql.core import graphql
32

4-
from ..models import *
5-
from ..schema import schema
63
from ..data import initialize
4+
from ..schema import schema
75

86
pytestmark = pytest.mark.django_db
97

examples/starwars_django/tests/test_mutation.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import pytest
2-
from ..schema import schema
2+
33
from ..data import initialize
4+
from ..schema import schema
45

56
pytestmark = pytest.mark.django_db
67

examples/starwars_django/tests/test_objectidentification.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import pytest
2-
from pytest import raises
3-
from graphql.core import graphql
4-
from ..data import initialize
52

3+
from ..data import initialize
64
from ..schema import schema
75

86
pytestmark = pytest.mark.django_db

0 commit comments

Comments
 (0)