Skip to content

Commit d805fe9

Browse files
committed
Apply black
1 parent 0cce083 commit d805fe9

24 files changed

+356
-148
lines changed

docs/conf.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,18 @@
6060
master_doc = "index"
6161

6262
# General information about the project.
63-
project = u"Graphene Django"
64-
copyright = u"Graphene 2017"
65-
author = u"Syrus Akbary"
63+
project = "Graphene Django"
64+
copyright = "Graphene 2017"
65+
author = "Syrus Akbary"
6666

6767
# The version info for the project you're documenting, acts as replacement for
6868
# |version| and |release|, also used in various other places throughout the
6969
# built documents.
7070
#
7171
# The short X.Y version.
72-
version = u"1.0"
72+
version = "1.0"
7373
# The full version, including alpha/beta/rc tags.
74-
release = u"1.0.dev"
74+
release = "1.0.dev"
7575

7676
# The language for content autogenerated by Sphinx. Refer to documentation
7777
# for a list of supported languages.
@@ -276,7 +276,7 @@
276276
# (source start file, target name, title,
277277
# author, documentclass [howto, manual, or own class]).
278278
latex_documents = [
279-
(master_doc, "Graphene.tex", u"Graphene Documentation", u"Syrus Akbary", "manual")
279+
(master_doc, "Graphene.tex", "Graphene Documentation", "Syrus Akbary", "manual")
280280
]
281281

282282
# The name of an image file (relative to this directory) to place at the top of
@@ -317,7 +317,7 @@
317317
# One entry per manual page. List of tuples
318318
# (source start file, name, description, authors, manual section).
319319
man_pages = [
320-
(master_doc, "graphene_django", u"Graphene Django Documentation", [author], 1)
320+
(master_doc, "graphene_django", "Graphene Django Documentation", [author], 1)
321321
]
322322

323323
# If true, show URL addresses after external links.
@@ -334,7 +334,7 @@
334334
(
335335
master_doc,
336336
"Graphene-Django",
337-
u"Graphene Django Documentation",
337+
"Graphene Django Documentation",
338338
author,
339339
"Graphene Django",
340340
"One line description of project.",

docs/schema.py

Lines changed: 36 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,55 @@
1-
import graphene
1+
import graphene
22

3-
from graphene_django.types import DjangoObjectType
3+
from graphene_django.types import DjangoObjectType
44

5-
from cookbook.ingredients.models import Category, Ingredient
5+
from cookbook.ingredients.models import Category, Ingredient
66

77

8-
class CategoryType(DjangoObjectType):
9-
class Meta:
10-
model = Category
8+
class CategoryType(DjangoObjectType):
9+
class Meta:
10+
model = Category
1111

1212

13-
class IngredientType(DjangoObjectType):
14-
class Meta:
15-
model = Ingredient
13+
class IngredientType(DjangoObjectType):
14+
class Meta:
15+
model = Ingredient
1616

1717

18-
class Query(object):
19-
category = graphene.Field(CategoryType,
20-
id=graphene.Int(),
21-
name=graphene.String())
22-
all_categories = graphene.List(CategoryType)
18+
class Query(object):
19+
category = graphene.Field(CategoryType, id=graphene.Int(), name=graphene.String())
20+
all_categories = graphene.List(CategoryType)
2321

22+
ingredient = graphene.Field(
23+
IngredientType, id=graphene.Int(), name=graphene.String()
24+
)
25+
all_ingredients = graphene.List(IngredientType)
2426

25-
ingredient = graphene.Field(IngredientType,
26-
id=graphene.Int(),
27-
name=graphene.String())
28-
all_ingredients = graphene.List(IngredientType)
27+
def resolve_all_categories(self, info, **kwargs):
28+
return Category.objects.all()
2929

30-
def resolve_all_categories(self, info, **kwargs):
31-
return Category.objects.all()
30+
def resolve_all_ingredients(self, info, **kwargs):
31+
return Ingredient.objects.all()
3232

33-
def resolve_all_ingredients(self, info, **kwargs):
34-
return Ingredient.objects.all()
33+
def resolve_category(self, info, **kwargs):
34+
id = kwargs.get("id")
35+
name = kwargs.get("name")
3536

36-
def resolve_category(self, info, **kwargs):
37-
id = kwargs.get('id')
38-
name = kwargs.get('name')
37+
if id is not None:
38+
return Category.objects.get(pk=id)
3939

40-
if id is not None:
41-
return Category.objects.get(pk=id)
40+
if name is not None:
41+
return Category.objects.get(name=name)
4242

43-
if name is not None:
44-
return Category.objects.get(name=name)
43+
return None
4544

46-
return None
45+
def resolve_ingredient(self, info, **kwargs):
46+
id = kwargs.get("id")
47+
name = kwargs.get("name")
4748

48-
def resolve_ingredient(self, info, **kwargs):
49-
id = kwargs.get('id')
50-
name = kwargs.get('name')
49+
if id is not None:
50+
return Ingredient.objects.get(pk=id)
5151

52-
if id is not None:
53-
return Ingredient.objects.get(pk=id)
52+
if name is not None:
53+
return Ingredient.objects.get(name=name)
5454

55-
if name is not None:
56-
return Ingredient.objects.get(name=name)
57-
58-
return None
55+
return None

examples/cookbook-plain/cookbook/ingredients/migrations/0001_initial.py

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,46 @@ class Migration(migrations.Migration):
1010

1111
initial = True
1212

13-
dependencies = [
14-
]
13+
dependencies = []
1514

1615
operations = [
1716
migrations.CreateModel(
18-
name='Category',
17+
name="Category",
1918
fields=[
20-
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
21-
('name', models.CharField(max_length=100)),
19+
(
20+
"id",
21+
models.AutoField(
22+
auto_created=True,
23+
primary_key=True,
24+
serialize=False,
25+
verbose_name="ID",
26+
),
27+
),
28+
("name", models.CharField(max_length=100)),
2229
],
2330
),
2431
migrations.CreateModel(
25-
name='Ingredient',
32+
name="Ingredient",
2633
fields=[
27-
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
28-
('name', models.CharField(max_length=100)),
29-
('notes', models.TextField()),
30-
('category', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='ingredients', to='ingredients.Category')),
34+
(
35+
"id",
36+
models.AutoField(
37+
auto_created=True,
38+
primary_key=True,
39+
serialize=False,
40+
verbose_name="ID",
41+
),
42+
),
43+
("name", models.CharField(max_length=100)),
44+
("notes", models.TextField()),
45+
(
46+
"category",
47+
models.ForeignKey(
48+
on_delete=django.db.models.deletion.CASCADE,
49+
related_name="ingredients",
50+
to="ingredients.Category",
51+
),
52+
),
3153
],
3254
),
3355
]

examples/cookbook-plain/cookbook/ingredients/migrations/0002_auto_20161104_0050.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
class Migration(migrations.Migration):
99

1010
dependencies = [
11-
('ingredients', '0001_initial'),
11+
("ingredients", "0001_initial"),
1212
]
1313

1414
operations = [
1515
migrations.AlterField(
16-
model_name='ingredient',
17-
name='notes',
16+
model_name="ingredient",
17+
name="notes",
1818
field=models.TextField(blank=True, null=True),
1919
),
2020
]

examples/cookbook-plain/cookbook/ingredients/migrations/0003_auto_20181018_1746.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
class Migration(migrations.Migration):
77

88
dependencies = [
9-
('ingredients', '0002_auto_20161104_0050'),
9+
("ingredients", "0002_auto_20161104_0050"),
1010
]
1111

1212
operations = [
1313
migrations.AlterModelOptions(
14-
name='category',
15-
options={'verbose_name_plural': 'Categories'},
14+
name="category",
15+
options={"verbose_name_plural": "Categories"},
1616
),
1717
]

examples/cookbook-plain/cookbook/recipes/migrations/0001_initial.py

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,62 @@ class Migration(migrations.Migration):
1111
initial = True
1212

1313
dependencies = [
14-
('ingredients', '0001_initial'),
14+
("ingredients", "0001_initial"),
1515
]
1616

1717
operations = [
1818
migrations.CreateModel(
19-
name='Recipe',
19+
name="Recipe",
2020
fields=[
21-
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
22-
('title', models.CharField(max_length=100)),
23-
('instructions', models.TextField()),
21+
(
22+
"id",
23+
models.AutoField(
24+
auto_created=True,
25+
primary_key=True,
26+
serialize=False,
27+
verbose_name="ID",
28+
),
29+
),
30+
("title", models.CharField(max_length=100)),
31+
("instructions", models.TextField()),
2432
],
2533
),
2634
migrations.CreateModel(
27-
name='RecipeIngredient',
35+
name="RecipeIngredient",
2836
fields=[
29-
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
30-
('amount', models.FloatField()),
31-
('unit', models.CharField(choices=[('kg', 'Kilograms'), ('l', 'Litres'), ('', 'Units')], max_length=20)),
32-
('ingredient', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='used_by', to='ingredients.Ingredient')),
33-
('recipes', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='amounts', to='recipes.Recipe')),
37+
(
38+
"id",
39+
models.AutoField(
40+
auto_created=True,
41+
primary_key=True,
42+
serialize=False,
43+
verbose_name="ID",
44+
),
45+
),
46+
("amount", models.FloatField()),
47+
(
48+
"unit",
49+
models.CharField(
50+
choices=[("kg", "Kilograms"), ("l", "Litres"), ("", "Units")],
51+
max_length=20,
52+
),
53+
),
54+
(
55+
"ingredient",
56+
models.ForeignKey(
57+
on_delete=django.db.models.deletion.CASCADE,
58+
related_name="used_by",
59+
to="ingredients.Ingredient",
60+
),
61+
),
62+
(
63+
"recipes",
64+
models.ForeignKey(
65+
on_delete=django.db.models.deletion.CASCADE,
66+
related_name="amounts",
67+
to="recipes.Recipe",
68+
),
69+
),
3470
],
3571
),
3672
]

examples/cookbook-plain/cookbook/recipes/migrations/0002_auto_20161104_0106.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,26 @@
88
class Migration(migrations.Migration):
99

1010
dependencies = [
11-
('recipes', '0001_initial'),
11+
("recipes", "0001_initial"),
1212
]
1313

1414
operations = [
1515
migrations.RenameField(
16-
model_name='recipeingredient',
17-
old_name='recipes',
18-
new_name='recipe',
16+
model_name="recipeingredient",
17+
old_name="recipes",
18+
new_name="recipe",
1919
),
2020
migrations.AlterField(
21-
model_name='recipeingredient',
22-
name='unit',
23-
field=models.CharField(choices=[(b'unit', b'Units'), (b'kg', b'Kilograms'), (b'l', b'Litres'), (b'st', b'Shots')], max_length=20),
21+
model_name="recipeingredient",
22+
name="unit",
23+
field=models.CharField(
24+
choices=[
25+
(b"unit", b"Units"),
26+
(b"kg", b"Kilograms"),
27+
(b"l", b"Litres"),
28+
(b"st", b"Shots"),
29+
],
30+
max_length=20,
31+
),
2432
),
2533
]

examples/cookbook-plain/cookbook/recipes/migrations/0003_auto_20181018_1728.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,21 @@
66
class Migration(migrations.Migration):
77

88
dependencies = [
9-
('recipes', '0002_auto_20161104_0106'),
9+
("recipes", "0002_auto_20161104_0106"),
1010
]
1111

1212
operations = [
1313
migrations.AlterField(
14-
model_name='recipeingredient',
15-
name='unit',
16-
field=models.CharField(choices=[('unit', 'Units'), ('kg', 'Kilograms'), ('l', 'Litres'), ('st', 'Shots')], max_length=20),
14+
model_name="recipeingredient",
15+
name="unit",
16+
field=models.CharField(
17+
choices=[
18+
("unit", "Units"),
19+
("kg", "Kilograms"),
20+
("l", "Litres"),
21+
("st", "Shots"),
22+
],
23+
max_length=20,
24+
),
1725
),
1826
]

0 commit comments

Comments
 (0)