Skip to content

Commit 43aec72

Browse files
authored
Merge pull request #793 from dan98765/add_black_formatter_precommit_hook
Add black formatter precommit hook
2 parents ae7395f + 142f4a5 commit 43aec72

File tree

109 files changed

+2413
-2595
lines changed

Some content is hidden

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

109 files changed

+2413
-2595
lines changed

.pre-commit-config.yaml

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@ repos:
22
- repo: git://github.com/pre-commit/pre-commit-hooks
33
rev: v1.3.0
44
hooks:
5-
- id: autopep8-wrapper
6-
args:
7-
- -i
8-
- --ignore=E128,E309,E501
9-
exclude: ^docs/.*$
105
- id: check-json
116
- id: check-yaml
127
- id: debug-statements
@@ -19,14 +14,11 @@ repos:
1914
- --autofix
2015
- id: flake8
2116
- repo: https://github.com/asottile/pyupgrade
22-
rev: v1.2.0
17+
rev: v1.4.0
2318
hooks:
2419
- id: pyupgrade
25-
- repo: https://github.com/asottile/seed-isort-config
26-
rev: v1.0.1
27-
hooks:
28-
- id: seed-isort-config
29-
- repo: https://github.com/pre-commit/mirrors-isort
30-
rev: v4.3.4
20+
- repo: https://github.com/ambv/black
21+
rev: 18.6b4
3122
hooks:
32-
- id: isort
23+
- id: black
24+
language_version: python3.6

docs/conf.py

Lines changed: 54 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import sphinx_graphene_theme
44

5-
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
5+
on_rtd = os.environ.get("READTHEDOCS", None) == "True"
66

77
# -*- coding: utf-8 -*-
88
#
@@ -36,46 +36,44 @@
3636
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3737
# ones.
3838
extensions = [
39-
'sphinx.ext.autodoc',
40-
'sphinx.ext.intersphinx',
41-
'sphinx.ext.todo',
42-
'sphinx.ext.coverage',
43-
'sphinx.ext.viewcode',
39+
"sphinx.ext.autodoc",
40+
"sphinx.ext.intersphinx",
41+
"sphinx.ext.todo",
42+
"sphinx.ext.coverage",
43+
"sphinx.ext.viewcode",
4444
]
4545
if not on_rtd:
46-
extensions += [
47-
'sphinx.ext.githubpages',
48-
]
46+
extensions += ["sphinx.ext.githubpages"]
4947

5048
# Add any paths that contain templates here, relative to this directory.
51-
templates_path = ['_templates']
49+
templates_path = ["_templates"]
5250

5351
# The suffix(es) of source filenames.
5452
# You can specify multiple suffix as a list of string:
5553
#
5654
# source_suffix = ['.rst', '.md']
57-
source_suffix = '.rst'
55+
source_suffix = ".rst"
5856

5957
# The encoding of source files.
6058
#
6159
# source_encoding = 'utf-8-sig'
6260

6361
# The master toctree document.
64-
master_doc = 'index'
62+
master_doc = "index"
6563

6664
# General information about the project.
67-
project = u'Graphene'
68-
copyright = u'Graphene 2016'
69-
author = u'Syrus Akbary'
65+
project = u"Graphene"
66+
copyright = u"Graphene 2016"
67+
author = u"Syrus Akbary"
7068

7169
# The version info for the project you're documenting, acts as replacement for
7270
# |version| and |release|, also used in various other places throughout the
7371
# built documents.
7472
#
7573
# The short X.Y version.
76-
version = u'1.0'
74+
version = u"1.0"
7775
# The full version, including alpha/beta/rc tags.
78-
release = u'1.0'
76+
release = u"1.0"
7977

8078
# The language for content autogenerated by Sphinx. Refer to documentation
8179
# for a list of supported languages.
@@ -96,7 +94,7 @@
9694
# List of patterns, relative to source directory, that match files and
9795
# directories to ignore when looking for source files.
9896
# This patterns also effect to html_static_path and html_extra_path
99-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
97+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
10098

10199
# The reST default role (used for this markup: `text`) to use for all
102100
# documents.
@@ -118,7 +116,7 @@
118116
# show_authors = False
119117

120118
# The name of the Pygments (syntax highlighting) style to use.
121-
pygments_style = 'sphinx'
119+
pygments_style = "sphinx"
122120

123121
# A list of ignored prefixes for module index sorting.
124122
# modindex_common_prefix = []
@@ -175,7 +173,7 @@
175173
# Add any paths that contain custom static files (such as style sheets) here,
176174
# relative to this directory. They are copied after the builtin static files,
177175
# so a file named "default.css" will overwrite the builtin "default.css".
178-
html_static_path = ['_static']
176+
html_static_path = ["_static"]
179177

180178
# Add any extra paths that contain custom files (such as robots.txt or
181179
# .htaccess) here, relative to this directory. These files are copied
@@ -255,34 +253,30 @@
255253
# html_search_scorer = 'scorer.js'
256254

257255
# Output file base name for HTML help builder.
258-
htmlhelp_basename = 'Graphenedoc'
256+
htmlhelp_basename = "Graphenedoc"
259257

260258
# -- Options for LaTeX output ---------------------------------------------
261259

262260
latex_elements = {
263-
# The paper size ('letterpaper' or 'a4paper').
264-
#
265-
# 'papersize': 'letterpaper',
266-
267-
# The font size ('10pt', '11pt' or '12pt').
268-
#
269-
# 'pointsize': '10pt',
270-
271-
# Additional stuff for the LaTeX preamble.
272-
#
273-
# 'preamble': '',
274-
275-
# Latex figure (float) alignment
276-
#
277-
# 'figure_align': 'htbp',
261+
# The paper size ('letterpaper' or 'a4paper').
262+
#
263+
# 'papersize': 'letterpaper',
264+
# The font size ('10pt', '11pt' or '12pt').
265+
#
266+
# 'pointsize': '10pt',
267+
# Additional stuff for the LaTeX preamble.
268+
#
269+
# 'preamble': '',
270+
# Latex figure (float) alignment
271+
#
272+
# 'figure_align': 'htbp',
278273
}
279274

280275
# Grouping the document tree into LaTeX files. List of tuples
281276
# (source start file, target name, title,
282277
# author, documentclass [howto, manual, or own class]).
283278
latex_documents = [
284-
(master_doc, 'Graphene.tex', u'Graphene Documentation',
285-
u'Syrus Akbary', 'manual'),
279+
(master_doc, "Graphene.tex", u"Graphene Documentation", u"Syrus Akbary", "manual")
286280
]
287281

288282
# The name of an image file (relative to this directory) to place at the top of
@@ -322,10 +316,7 @@
322316

323317
# One entry per manual page. List of tuples
324318
# (source start file, name, description, authors, manual section).
325-
man_pages = [
326-
(master_doc, 'graphene', u'Graphene Documentation',
327-
[author], 1)
328-
]
319+
man_pages = [(master_doc, "graphene", u"Graphene Documentation", [author], 1)]
329320

330321
# If true, show URL addresses after external links.
331322
#
@@ -338,9 +329,15 @@
338329
# (source start file, target name, title, author,
339330
# dir menu entry, description, category)
340331
texinfo_documents = [
341-
(master_doc, 'Graphene', u'Graphene Documentation',
342-
author, 'Graphene', 'One line description of project.',
343-
'Miscellaneous'),
332+
(
333+
master_doc,
334+
"Graphene",
335+
u"Graphene Documentation",
336+
author,
337+
"Graphene",
338+
"One line description of project.",
339+
"Miscellaneous",
340+
)
344341
]
345342

346343
# Documents to append as an appendix to all manuals.
@@ -414,7 +411,7 @@
414411
# epub_post_files = []
415412

416413
# A list of files that should not be packed into the epub file.
417-
epub_exclude_files = ['search.html']
414+
epub_exclude_files = ["search.html"]
418415

419416
# The depth of the table of contents in toc.ncx.
420417
#
@@ -447,9 +444,15 @@
447444

448445
# Example configuration for intersphinx: refer to the Python standard library.
449446
intersphinx_mapping = {
450-
'https://docs.python.org/': None,
451-
'python': ('https://docs.python.org/', None),
452-
'graphene_django': ('http://docs.graphene-python.org/projects/django/en/latest/', None),
453-
'graphene_sqlalchemy': ('http://docs.graphene-python.org/projects/sqlalchemy/en/latest/', None),
454-
'graphene_gae': ('http://docs.graphene-python.org/projects/gae/en/latest/', None),
447+
"https://docs.python.org/": None,
448+
"python": ("https://docs.python.org/", None),
449+
"graphene_django": (
450+
"http://docs.graphene-python.org/projects/django/en/latest/",
451+
None,
452+
),
453+
"graphene_sqlalchemy": (
454+
"http://docs.graphene-python.org/projects/sqlalchemy/en/latest/",
455+
None,
456+
),
457+
"graphene_gae": ("http://docs.graphene-python.org/projects/gae/en/latest/", None),
455458
}

examples/complex_example.py

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ def resolve_address(self, info, geo):
2222

2323

2424
class CreateAddress(graphene.Mutation):
25-
2625
class Arguments:
2726
geo = GeoInput(required=True)
2827

@@ -37,42 +36,34 @@ class Mutation(graphene.ObjectType):
3736

3837

3938
schema = graphene.Schema(query=Query, mutation=Mutation)
40-
query = '''
39+
query = """
4140
query something{
4241
address(geo: {lat:32.2, lng:12}) {
4342
latlng
4443
}
4544
}
46-
'''
47-
mutation = '''
45+
"""
46+
mutation = """
4847
mutation addAddress{
4948
createAddress(geo: {lat:32.2, lng:12}) {
5049
latlng
5150
}
5251
}
53-
'''
52+
"""
5453

5554

5655
def test_query():
5756
result = schema.execute(query)
5857
assert not result.errors
59-
assert result.data == {
60-
'address': {
61-
'latlng': "(32.2,12.0)",
62-
}
63-
}
58+
assert result.data == {"address": {"latlng": "(32.2,12.0)"}}
6459

6560

6661
def test_mutation():
6762
result = schema.execute(mutation)
6863
assert not result.errors
69-
assert result.data == {
70-
'createAddress': {
71-
'latlng': "(32.2,12.0)",
72-
}
73-
}
64+
assert result.data == {"createAddress": {"latlng": "(32.2,12.0)"}}
7465

7566

76-
if __name__ == '__main__':
67+
if __name__ == "__main__":
7768
result = schema.execute(query)
78-
print(result.data['address']['latlng'])
69+
print(result.data["address"]["latlng"])

examples/context_example.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,26 @@ class Query(graphene.ObjectType):
1010
me = graphene.Field(User)
1111

1212
def resolve_me(self, info):
13-
return info.context['user']
13+
return info.context["user"]
1414

1515

1616
schema = graphene.Schema(query=Query)
17-
query = '''
17+
query = """
1818
query something{
1919
me {
2020
id
2121
name
2222
}
2323
}
24-
'''
24+
"""
2525

2626

2727
def test_query():
28-
result = schema.execute(query, context_value={'user': User(id='1', name='Syrus')})
28+
result = schema.execute(query, context_value={"user": User(id="1", name="Syrus")})
2929
assert not result.errors
30-
assert result.data == {
31-
'me': {
32-
'id': '1',
33-
'name': 'Syrus',
34-
}
35-
}
30+
assert result.data == {"me": {"id": "1", "name": "Syrus"}}
3631

3732

38-
if __name__ == '__main__':
39-
result = schema.execute(query, context_value={'user': User(id='X', name='Console')})
40-
print(result.data['me'])
33+
if __name__ == "__main__":
34+
result = schema.execute(query, context_value={"user": User(id="X", name="Console")})
35+
print(result.data["me"])

examples/simple_example.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,27 @@ class Query(graphene.ObjectType):
1212
patron = graphene.Field(Patron)
1313

1414
def resolve_patron(self, info):
15-
return Patron(id=1, name='Syrus', age=27)
15+
return Patron(id=1, name="Syrus", age=27)
1616

1717

1818
schema = graphene.Schema(query=Query)
19-
query = '''
19+
query = """
2020
query something{
2121
patron {
2222
id
2323
name
2424
age
2525
}
2626
}
27-
'''
27+
"""
2828

2929

3030
def test_query():
3131
result = schema.execute(query)
3232
assert not result.errors
33-
assert result.data == {
34-
'patron': {
35-
'id': '1',
36-
'name': 'Syrus',
37-
'age': 27,
38-
}
39-
}
33+
assert result.data == {"patron": {"id": "1", "name": "Syrus", "age": 27}}
4034

4135

42-
if __name__ == '__main__':
36+
if __name__ == "__main__":
4337
result = schema.execute(query)
44-
print(result.data['patron'])
38+
print(result.data["patron"])

0 commit comments

Comments
 (0)