Skip to content

Commit b3657b0

Browse files
authored
Add Black to pre-commit (#361)
This commits re-formats the codebase using black
1 parent 43df4eb commit b3657b0

33 files changed

+1041
-698
lines changed

.flake8

-4
This file was deleted.

.pre-commit-config.yaml

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
default_language_version:
2-
python: python3.10
2+
python: python3.7
33
repos:
44
- repo: https://github.com/pre-commit/pre-commit-hooks
55
rev: v4.2.0
@@ -16,6 +16,14 @@ repos:
1616
hooks:
1717
- id: isort
1818
name: isort (python)
19+
- repo: https://github.com/asottile/pyupgrade
20+
rev: v2.37.3
21+
hooks:
22+
- id: pyupgrade
23+
- repo: https://github.com/psf/black
24+
rev: 22.6.0
25+
hooks:
26+
- id: black
1927
- repo: https://github.com/PyCQA/flake8
2028
rev: 4.0.0
2129
hooks:

docs/conf.py

+44-43
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
22

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

55
# -*- coding: utf-8 -*-
66
#
@@ -34,46 +34,46 @@
3434
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3535
# ones.
3636
extensions = [
37-
'sphinx.ext.autodoc',
38-
'sphinx.ext.intersphinx',
39-
'sphinx.ext.todo',
40-
'sphinx.ext.coverage',
41-
'sphinx.ext.viewcode',
37+
"sphinx.ext.autodoc",
38+
"sphinx.ext.intersphinx",
39+
"sphinx.ext.todo",
40+
"sphinx.ext.coverage",
41+
"sphinx.ext.viewcode",
4242
]
4343
if not on_rtd:
4444
extensions += [
45-
'sphinx.ext.githubpages',
45+
"sphinx.ext.githubpages",
4646
]
4747

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

5151
# The suffix(es) of source filenames.
5252
# You can specify multiple suffix as a list of string:
5353
#
5454
# source_suffix = ['.rst', '.md']
55-
source_suffix = '.rst'
55+
source_suffix = ".rst"
5656

5757
# The encoding of source files.
5858
#
5959
# source_encoding = 'utf-8-sig'
6060

6161
# The master toctree document.
62-
master_doc = 'index'
62+
master_doc = "index"
6363

6464
# General information about the project.
65-
project = u'Graphene Django'
66-
copyright = u'Graphene 2016'
67-
author = u'Syrus Akbary'
65+
project = "Graphene Django"
66+
copyright = "Graphene 2016"
67+
author = "Syrus Akbary"
6868

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

7878
# The language for content autogenerated by Sphinx. Refer to documentation
7979
# for a list of supported languages.
@@ -94,7 +94,7 @@
9494
# List of patterns, relative to source directory, that match files and
9595
# directories to ignore when looking for source files.
9696
# This patterns also effect to html_static_path and html_extra_path
97-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
97+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
9898

9999
# The reST default role (used for this markup: `text`) to use for all
100100
# documents.
@@ -116,7 +116,7 @@
116116
# show_authors = False
117117

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

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

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

257257
# Output file base name for HTML help builder.
258-
htmlhelp_basename = 'Graphenedoc'
258+
htmlhelp_basename = "Graphenedoc"
259259

260260
# -- Options for LaTeX output ---------------------------------------------
261261

262262
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',
263+
# The paper size ('letterpaper' or 'a4paper').
264+
#
265+
# 'papersize': 'letterpaper',
266+
# The font size ('10pt', '11pt' or '12pt').
267+
#
268+
# 'pointsize': '10pt',
269+
# Additional stuff for the LaTeX preamble.
270+
#
271+
# 'preamble': '',
272+
# Latex figure (float) alignment
273+
#
274+
# 'figure_align': 'htbp',
278275
}
279276

280277
# Grouping the document tree into LaTeX files. List of tuples
281278
# (source start file, target name, title,
282279
# author, documentclass [howto, manual, or own class]).
283280
latex_documents = [
284-
(master_doc, 'Graphene.tex', u'Graphene Documentation',
285-
u'Syrus Akbary', 'manual'),
281+
(master_doc, "Graphene.tex", "Graphene Documentation", "Syrus Akbary", "manual"),
286282
]
287283

288284
# The name of an image file (relative to this directory) to place at the top of
@@ -323,8 +319,7 @@
323319
# One entry per manual page. List of tuples
324320
# (source start file, name, description, authors, manual section).
325321
man_pages = [
326-
(master_doc, 'graphene_django', u'Graphene Django Documentation',
327-
[author], 1)
322+
(master_doc, "graphene_django", "Graphene Django Documentation", [author], 1)
328323
]
329324

330325
# If true, show URL addresses after external links.
@@ -338,9 +333,15 @@
338333
# (source start file, target name, title, author,
339334
# dir menu entry, description, category)
340335
texinfo_documents = [
341-
(master_doc, 'Graphene-Django', u'Graphene Django Documentation',
342-
author, 'Graphene Django', 'One line description of project.',
343-
'Miscellaneous'),
336+
(
337+
master_doc,
338+
"Graphene-Django",
339+
"Graphene Django Documentation",
340+
author,
341+
"Graphene Django",
342+
"One line description of project.",
343+
"Miscellaneous",
344+
),
344345
]
345346

346347
# Documents to append as an appendix to all manuals.
@@ -414,7 +415,7 @@
414415
# epub_post_files = []
415416

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

419420
# The depth of the table of contents in toc.ncx.
420421
#
@@ -446,4 +447,4 @@
446447

447448

448449
# Example configuration for intersphinx: refer to the Python standard library.
449-
intersphinx_mapping = {'https://docs.python.org/': None}
450+
intersphinx_mapping = {"https://docs.python.org/": None}

examples/flask_sqlalchemy/database.py

+12-11
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
from sqlalchemy.ext.declarative import declarative_base
33
from sqlalchemy.orm import scoped_session, sessionmaker
44

5-
engine = create_engine('sqlite:///database.sqlite3', convert_unicode=True)
6-
db_session = scoped_session(sessionmaker(autocommit=False,
7-
autoflush=False,
8-
bind=engine))
5+
engine = create_engine("sqlite:///database.sqlite3", convert_unicode=True)
6+
db_session = scoped_session(
7+
sessionmaker(autocommit=False, autoflush=False, bind=engine)
8+
)
99
Base = declarative_base()
1010
Base.query = db_session.query_property()
1111

@@ -15,24 +15,25 @@ def init_db():
1515
# they will be registered properly on the metadata. Otherwise
1616
# you will have to import them first before calling init_db()
1717
from models import Department, Employee, Role
18+
1819
Base.metadata.drop_all(bind=engine)
1920
Base.metadata.create_all(bind=engine)
2021

2122
# Create the fixtures
22-
engineering = Department(name='Engineering')
23+
engineering = Department(name="Engineering")
2324
db_session.add(engineering)
24-
hr = Department(name='Human Resources')
25+
hr = Department(name="Human Resources")
2526
db_session.add(hr)
2627

27-
manager = Role(name='manager')
28+
manager = Role(name="manager")
2829
db_session.add(manager)
29-
engineer = Role(name='engineer')
30+
engineer = Role(name="engineer")
3031
db_session.add(engineer)
3132

32-
peter = Employee(name='Peter', department=engineering, role=engineer)
33+
peter = Employee(name="Peter", department=engineering, role=engineer)
3334
db_session.add(peter)
34-
roy = Employee(name='Roy', department=engineering, role=engineer)
35+
roy = Employee(name="Roy", department=engineering, role=engineer)
3536
db_session.add(roy)
36-
tracy = Employee(name='Tracy', department=hr, role=manager)
37+
tracy = Employee(name="Tracy", department=hr, role=manager)
3738
db_session.add(tracy)
3839
db_session.commit()

examples/flask_sqlalchemy/models.py

+9-13
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,31 @@
44

55

66
class Department(Base):
7-
__tablename__ = 'department'
7+
__tablename__ = "department"
88
id = Column(Integer, primary_key=True)
99
name = Column(String)
1010

1111

1212
class Role(Base):
13-
__tablename__ = 'roles'
13+
__tablename__ = "roles"
1414
role_id = Column(Integer, primary_key=True)
1515
name = Column(String)
1616

1717

1818
class Employee(Base):
19-
__tablename__ = 'employee'
19+
__tablename__ = "employee"
2020
id = Column(Integer, primary_key=True)
2121
name = Column(String)
2222
# Use default=func.now() to set the default hiring time
2323
# of an Employee to be the current time when an
2424
# Employee record was created
2525
hired_on = Column(DateTime, default=func.now())
26-
department_id = Column(Integer, ForeignKey('department.id'))
27-
role_id = Column(Integer, ForeignKey('roles.role_id'))
26+
department_id = Column(Integer, ForeignKey("department.id"))
27+
role_id = Column(Integer, ForeignKey("roles.role_id"))
2828
# Use cascade='delete,all' to propagate the deletion of a Department onto its Employees
2929
department = relationship(
30-
Department,
31-
backref=backref('employees',
32-
uselist=True,
33-
cascade='delete,all'))
30+
Department, backref=backref("employees", uselist=True, cascade="delete,all")
31+
)
3432
role = relationship(
35-
Role,
36-
backref=backref('roles',
37-
uselist=True,
38-
cascade='delete,all'))
33+
Role, backref=backref("roles", uselist=True, cascade="delete,all")
34+
)

examples/flask_sqlalchemy/schema.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,27 @@
1010
class Department(SQLAlchemyObjectType):
1111
class Meta:
1212
model = DepartmentModel
13-
interfaces = (relay.Node, )
13+
interfaces = (relay.Node,)
1414

1515

1616
class Employee(SQLAlchemyObjectType):
1717
class Meta:
1818
model = EmployeeModel
19-
interfaces = (relay.Node, )
19+
interfaces = (relay.Node,)
2020

2121

2222
class Role(SQLAlchemyObjectType):
2323
class Meta:
2424
model = RoleModel
25-
interfaces = (relay.Node, )
25+
interfaces = (relay.Node,)
2626

2727

2828
class Query(graphene.ObjectType):
2929
node = relay.Node.Field()
3030
# Allow only single column sorting
3131
all_employees = SQLAlchemyConnectionField(
32-
Employee.connection, sort=Employee.sort_argument())
32+
Employee.connection, sort=Employee.sort_argument()
33+
)
3334
# Allows sorting over multiple columns, by default over the primary key
3435
all_roles = SQLAlchemyConnectionField(Role.connection)
3536
# Disable sorting over this field

0 commit comments

Comments
 (0)