Skip to content

Commit 9a43f65

Browse files
authored
Merge pull request #623 from graphql-python/black
Introduce Black formatting, additional tests
2 parents 05c89c1 + e6ad588 commit 9a43f65

File tree

15 files changed

+86
-62
lines changed

15 files changed

+86
-62
lines changed

.travis.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
language: python
2-
sudo: false
2+
sudo: required
3+
dist: xenial
34
python:
45
- 2.7
56
- 3.4
67
- 3.5
78
- 3.6
9+
- 3.7
810
install:
911
- |
1012
if [ "$TEST_TYPE" = build ]; then
1113
pip install -e .[test]
12-
pip install psycopg2 # Required for Django postgres fields testing
14+
pip install psycopg2==2.8.2 # Required for Django postgres fields testing
1315
pip install django==$DJANGO_VERSION
1416
python setup.py develop
1517
elif [ "$TEST_TYPE" = lint ]; then
16-
pip install flake8
18+
pip install flake8==3.7.7
1719
fi
1820
script:
1921
- |
@@ -45,10 +47,16 @@ matrix:
4547
env: TEST_TYPE=build DJANGO_VERSION=2.1
4648
- python: '3.6'
4749
env: TEST_TYPE=build DJANGO_VERSION=2.1
50+
- python: '3.6'
51+
env: TEST_TYPE=build DJANGO_VERSION=2.2
52+
- python: '3.7'
53+
env: TEST_TYPE=build DJANGO_VERSION=2.2
4854
- python: '2.7'
4955
env: TEST_TYPE=lint
5056
- python: '3.6'
5157
env: TEST_TYPE=lint
58+
- python: '3.7'
59+
env: TEST_TYPE=lint
5260
deploy:
5361
provider: pypi
5462
user: syrusakbary

CONTRIBUTING.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,19 @@ After developing, the full test suite can be evaluated by running:
3131
make tests
3232
```
3333

34+
## Opening Pull Requests
35+
36+
Please fork the project and open a pull request against the master branch.
37+
38+
This will trigger a series of test and lint checks.
39+
40+
We advise that you format and run lint locally before doing this to save time:
41+
42+
```sh
43+
make format
44+
make lint
45+
```
46+
3447
## Documentation
3548

3649
The [documentation](http://docs.graphene-python.org/projects/django/en/latest/) is generated using the excellent [Sphinx](http://www.sphinx-doc.org/) and a custom theme.

Makefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
dev-setup:
2-
pip install -e ".[test]"
2+
pip install -e ".[dev]"
33

44
tests:
5-
py.test graphene_django --cov=graphene_django -vv
5+
py.test graphene_django --cov=graphene_django -vv
6+
7+
format:
8+
black graphene_django
9+
10+
lint:
11+
flake8 graphene_django

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,4 @@ To learn more check out the following [examples](examples/):
9696

9797
## Contributing
9898

99-
See [CONTRIBUTING.md](contributing.md)
99+
See [CONTRIBUTING.md](CONTRIBUTING.md)

graphene_django/compat.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ class MissingType(object):
55
try:
66
# Postgres fields are only available in Django with psycopg2 installed
77
# and we cannot have psycopg2 on PyPy
8-
from django.contrib.postgres.fields import (ArrayField, HStoreField,
9-
JSONField, RangeField)
8+
from django.contrib.postgres.fields import (
9+
ArrayField,
10+
HStoreField,
11+
JSONField,
12+
RangeField,
13+
)
1014
except ImportError:
1115
ArrayField, HStoreField, JSONField, RangeField = (MissingType,) * 4

graphene_django/debug/sql/types.py

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33

44
class DjangoDebugSQL(ObjectType):
55
class Meta:
6-
description = (
7-
"Represents a single database query made to a Django managed DB."
8-
)
6+
description = "Represents a single database query made to a Django managed DB."
97

108
vendor = String(
119
required=True,
@@ -14,37 +12,26 @@ class Meta:
1412
),
1513
)
1614
alias = String(
17-
required=True,
18-
description="The Django database alias (e.g. 'default').",
15+
required=True, description="The Django database alias (e.g. 'default')."
1916
)
2017
sql = String(description="The actual SQL sent to this database.")
2118
duration = Float(
22-
required=True,
23-
description="Duration of this database query in seconds.",
19+
required=True, description="Duration of this database query in seconds."
2420
)
2521
raw_sql = String(
26-
required=True,
27-
description="The raw SQL of this query, without params.",
22+
required=True, description="The raw SQL of this query, without params."
2823
)
2924
params = String(
30-
required=True,
31-
description="JSON encoded database query parameters.",
32-
)
33-
start_time = Float(
34-
required=True,
35-
description="Start time of this database query.",
36-
)
37-
stop_time = Float(
38-
required=True,
39-
description="Stop time of this database query.",
25+
required=True, description="JSON encoded database query parameters."
4026
)
27+
start_time = Float(required=True, description="Start time of this database query.")
28+
stop_time = Float(required=True, description="Stop time of this database query.")
4129
is_slow = Boolean(
4230
required=True,
4331
description="Whether this database query took more than 10 seconds.",
4432
)
4533
is_select = Boolean(
46-
required=True,
47-
description="Whether this database query was a SELECT.",
34+
required=True, description="Whether this database query was a SELECT."
4835
)
4936

5037
# Postgres

graphene_django/debug/types.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,4 @@ class DjangoDebug(ObjectType):
77
class Meta:
88
description = "Debugging information for the current query."
99

10-
sql = List(
11-
DjangoDebugSQL,
12-
description="Executed SQL queries for this API query.",
13-
)
10+
sql = List(DjangoDebugSQL, description="Executed SQL queries for this API query.")

graphene_django/filter/filterset.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ class GrapheneFilterSetMixin(BaseFilterSet):
4545

4646
FILTER_DEFAULTS = dict(
4747
itertools.chain(
48-
FILTER_FOR_DBFIELD_DEFAULTS.items(),
49-
GRAPHENE_FILTER_SET_OVERRIDES.items()
48+
FILTER_FOR_DBFIELD_DEFAULTS.items(), GRAPHENE_FILTER_SET_OVERRIDES.items()
5049
)
5150
)
5251

@@ -59,7 +58,6 @@ class GrapheneFilterSetMixin(BaseFilterSet):
5958
from django.utils.text import capfirst
6059

6160
class GrapheneFilterSetMixinPython2(GrapheneFilterSetMixin):
62-
6361
@classmethod
6462
def filter_for_reverse_field(cls, f, name):
6563
"""Handles retrieving filters for reverse relationships

graphene_django/forms/tests/test_mutation.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class MyForm(forms.Form):
1313
class PetForm(forms.ModelForm):
1414
class Meta:
1515
model = Pet
16-
fields = '__all__'
16+
fields = "__all__"
1717

1818

1919
def test_needs_form_class():
@@ -66,7 +66,7 @@ def test_exclude_fields_input_meta_fields(self):
6666
class PetMutation(DjangoModelFormMutation):
6767
class Meta:
6868
form_class = PetForm
69-
exclude_fields = ['id']
69+
exclude_fields = ["id"]
7070

7171
self.assertEqual(PetMutation._meta.model, Pet)
7272
self.assertEqual(PetMutation._meta.return_field_name, "pet")
@@ -102,7 +102,9 @@ class Meta:
102102

103103
pet = Pet.objects.create(name="Axel", age=10)
104104

105-
result = PetMutation.mutate_and_get_payload(None, None, id=pet.pk, name="Mia", age=10)
105+
result = PetMutation.mutate_and_get_payload(
106+
None, None, id=pet.pk, name="Mia", age=10
107+
)
106108

107109
self.assertEqual(Pet.objects.count(), 1)
108110
pet.refresh_from_db()
@@ -132,7 +134,6 @@ class Meta:
132134
# A pet was not created
133135
self.assertEqual(Pet.objects.count(), 0)
134136

135-
136137
fields_w_error = [e.field for e in result.errors]
137138
self.assertEqual(len(result.errors), 2)
138139
self.assertIn("name", fields_w_error)

graphene_django/management/commands/graphql_schema.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def handle(self, *args, **options):
6464

6565
indent = options.get("indent")
6666
schema_dict = {"data": schema.introspect()}
67-
if out == '-':
67+
if out == "-":
6868
self.stdout.write(json.dumps(schema_dict, indent=indent, sort_keys=True))
6969
else:
7070
self.save_file(out, schema_dict, indent)

0 commit comments

Comments
 (0)