Skip to content

Commit 5efd5f3

Browse files
authored
Blacken proto-pus (#42)
1 parent cd224ff commit 5efd5f3

Some content is hidden

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

45 files changed

+612
-599
lines changed

packages/proto-plus/docs/conf.py

Lines changed: 43 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,20 @@
1414
#
1515
import os
1616
import sys
17-
sys.path.insert(0, os.path.abspath('..'))
17+
18+
sys.path.insert(0, os.path.abspath(".."))
1819

1920

2021
# -- Project information -----------------------------------------------------
2122

22-
project = 'Proto Plus for Python'
23-
copyright = '2018, Google LLC'
24-
author = 'Luke Sneeringer'
23+
project = "Proto Plus for Python"
24+
copyright = "2018, Google LLC"
25+
author = "Luke Sneeringer"
2526

2627
# The short X.Y version
27-
version = '0.1.0'
28+
version = "0.1.0"
2829
# The full version, including alpha/beta/rc tags
29-
release = '0.1.0'
30+
release = "0.1.0"
3031

3132

3233
# -- General configuration ---------------------------------------------------
@@ -39,24 +40,24 @@
3940
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
4041
# ones.
4142
extensions = [
42-
'sphinx.ext.autodoc',
43-
'sphinx.ext.intersphinx',
44-
'sphinx.ext.viewcode',
45-
'sphinx.ext.githubpages',
46-
'sphinx.ext.napoleon',
43+
"sphinx.ext.autodoc",
44+
"sphinx.ext.intersphinx",
45+
"sphinx.ext.viewcode",
46+
"sphinx.ext.githubpages",
47+
"sphinx.ext.napoleon",
4748
]
4849

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

5253
# The suffix(es) of source filenames.
5354
# You can specify multiple suffix as a list of string:
5455
#
5556
# source_suffix = ['.rst', '.md']
56-
source_suffix = '.rst'
57+
source_suffix = ".rst"
5758

5859
# The master toctree document.
59-
master_doc = 'index'
60+
master_doc = "index"
6061

6162
# The language for content autogenerated by Sphinx. Refer to documentation
6263
# for a list of supported languages.
@@ -68,18 +69,18 @@
6869
# List of patterns, relative to source directory, that match files and
6970
# directories to ignore when looking for source files.
7071
# This pattern also affects html_static_path and html_extra_path .
71-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
72+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
7273

7374
# The name of the Pygments (syntax highlighting) style to use.
74-
pygments_style = 'sphinx'
75+
pygments_style = "sphinx"
7576

7677

7778
# -- Options for HTML output -------------------------------------------------
7879

7980
# The theme to use for HTML and HTML Help pages. See the documentation for
8081
# a list of builtin themes.
8182
#
82-
html_theme = 'sphinx_rtd_theme'
83+
html_theme = "sphinx_rtd_theme"
8384

8485
# Theme options are theme-specific and customize the look and feel of a theme
8586
# further. For a list of options available for each theme, see the
@@ -106,7 +107,7 @@
106107
# -- Options for HTMLHelp output ---------------------------------------------
107108

108109
# Output file base name for HTML help builder.
109-
htmlhelp_basename = 'proto-plus-python'
110+
htmlhelp_basename = "proto-plus-python"
110111

111112

112113
# -- Options for LaTeX output ------------------------------------------------
@@ -115,15 +116,12 @@
115116
# The paper size ('letterpaper' or 'a4paper').
116117
#
117118
# 'papersize': 'letterpaper',
118-
119119
# The font size ('10pt', '11pt' or '12pt').
120120
#
121121
# 'pointsize': '10pt',
122-
123122
# Additional stuff for the LaTeX preamble.
124123
#
125124
# 'preamble': '',
126-
127125
# Latex figure (float) alignmentAPIClientGeneratorforPython
128126
#
129127
# 'figure_align': 'htbp',
@@ -133,8 +131,13 @@
133131
# (source start file, target name, title,
134132
# author, documentclass [howto, manual, or own class]).
135133
latex_documents = [
136-
(master_doc, 'proto-plus-python.tex', 'Proto Plus for Python Documentation',
137-
'Luke Sneeringer', 'manual'),
134+
(
135+
master_doc,
136+
"proto-plus-python.tex",
137+
"Proto Plus for Python Documentation",
138+
"Luke Sneeringer",
139+
"manual",
140+
),
138141
]
139142

140143

@@ -143,8 +146,13 @@
143146
# One entry per manual page. List of tuples
144147
# (source start file, name, description, authors, manual section).
145148
man_pages = [
146-
(master_doc, 'proto-plus-python', 'Proto Plus for Python Documentation',
147-
[author], 1)
149+
(
150+
master_doc,
151+
"proto-plus-python",
152+
"Proto Plus for Python Documentation",
153+
[author],
154+
1,
155+
)
148156
]
149157

150158

@@ -154,9 +162,15 @@
154162
# (source start file, target name, title, author,
155163
# dir menu entry, description, category)
156164
texinfo_documents = [
157-
(master_doc, 'proto-plus-python', 'Proto Plus for Python Documentation',
158-
author, 'proto-plus-python', 'One line description of project.',
159-
'Miscellaneous'),
165+
(
166+
master_doc,
167+
"proto-plus-python",
168+
"Proto Plus for Python Documentation",
169+
author,
170+
"proto-plus-python",
171+
"One line description of project.",
172+
"Miscellaneous",
173+
),
160174
]
161175

162176

@@ -165,4 +179,4 @@
165179
# -- Options for intersphinx extension ---------------------------------------
166180

167181
# Example configuration for intersphinx: refer to the Python standard library.
168-
intersphinx_mapping = {'https://docs.python.org/3/': None}
182+
intersphinx_mapping = {"https://docs.python.org/3/": None}

packages/proto-plus/noxfile.py

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,39 +18,47 @@
1818
import nox
1919

2020

21-
@nox.session(python=['3.5', '3.6', '3.7'])
22-
def unit(session, proto='python'):
21+
@nox.session(python=["3.5", "3.6", "3.7"])
22+
def unit(session, proto="python"):
2323
"""Run the unit test suite."""
2424

25-
session.env['PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION'] = proto
26-
session.install('coverage', 'pytest', 'pytest-cov')
27-
session.install('-e', '.')
25+
session.env["PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION"] = proto
26+
session.install("coverage", "pytest", "pytest-cov")
27+
session.install("-e", ".")
2828

2929
session.run(
30-
'py.test',
31-
'-W=error',
32-
'--quiet',
33-
'--cov=proto',
34-
'--cov-config=.coveragerc',
35-
'--cov-report=term',
36-
'--cov-report=html',
37-
os.path.join('tests', ''),
30+
"py.test",
31+
"-W=error",
32+
"--quiet",
33+
"--cov=proto",
34+
"--cov-config=.coveragerc",
35+
"--cov-report=term",
36+
"--cov-report=html",
37+
os.path.join("tests", ""),
3838
)
3939

4040

41-
@nox.session(python=['3.5', '3.6', '3.7'])
41+
@nox.session(python=["3.5", "3.6", "3.7"])
4242
def unitcpp(session):
43-
return unit(session, proto='cpp')
43+
return unit(session, proto="cpp")
4444

4545

46-
@nox.session(python='3.6')
46+
@nox.session(python="3.6")
4747
def docs(session):
4848
"""Build the docs."""
4949

50-
session.install('sphinx', 'sphinx_rtd_theme')
51-
session.install('.')
50+
session.install("sphinx", "sphinx_rtd_theme")
51+
session.install(".")
5252

5353
# Build the docs!
54-
session.run('rm', '-rf', 'docs/_build/')
55-
session.run('sphinx-build', '-W', '-b', 'html', '-d',
56-
'docs/_build/doctrees', 'docs/', 'docs/_build/html/')
54+
session.run("rm", "-rf", "docs/_build/")
55+
session.run(
56+
"sphinx-build",
57+
"-W",
58+
"-b",
59+
"html",
60+
"-d",
61+
"docs/_build/doctrees",
62+
"docs/",
63+
"docs/_build/html/",
64+
)

packages/proto-plus/proto/__init__.py

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -42,30 +42,29 @@
4242

4343

4444
__all__ = (
45-
'Enum',
46-
'Field',
47-
'MapField',
48-
'RepeatedField',
49-
'Marshal',
50-
'Message',
51-
'module',
52-
45+
"Enum",
46+
"Field",
47+
"MapField",
48+
"RepeatedField",
49+
"Marshal",
50+
"Message",
51+
"module",
5352
# Expose the types directly.
54-
'DOUBLE',
55-
'FLOAT',
56-
'INT64',
57-
'UINT64',
58-
'INT32',
59-
'FIXED64',
60-
'FIXED32',
61-
'BOOL',
62-
'STRING',
63-
'MESSAGE',
64-
'BYTES',
65-
'UINT32',
66-
'ENUM',
67-
'SFIXED32',
68-
'SFIXED64',
69-
'SINT32',
70-
'SINT64',
53+
"DOUBLE",
54+
"FLOAT",
55+
"INT64",
56+
"UINT64",
57+
"INT32",
58+
"FIXED64",
59+
"FIXED32",
60+
"BOOL",
61+
"STRING",
62+
"MESSAGE",
63+
"BYTES",
64+
"UINT32",
65+
"ENUM",
66+
"SFIXED32",
67+
"SFIXED64",
68+
"SINT32",
69+
"SINT64",
7170
)

packages/proto-plus/proto/_file_info.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@
2424
from proto.marshal.rules.message import MessageRule
2525

2626

27-
class _FileInfo(collections.namedtuple(
28-
'_FileInfo', ['descriptor', 'messages', 'enums', 'name', 'nested'])):
27+
class _FileInfo(
28+
collections.namedtuple(
29+
"_FileInfo", ["descriptor", "messages", "enums", "name", "nested"]
30+
)
31+
):
2932
registry = {} # Mapping[str, '_FileInfo']
3033

3134
def generate_file_pb(self):
@@ -44,9 +47,8 @@ def generate_file_pb(self):
4447
# Salt the filename in the descriptor.
4548
# This allows re-use of the filename by other proto messages if
4649
# needed (e.g. if __all__ is not used).
47-
self.descriptor.name = '{prefix}_{salt}.proto'.format(
48-
prefix=self.descriptor.name[:-6],
49-
salt=str(uuid.uuid4())[0:8],
50+
self.descriptor.name = "{prefix}_{salt}.proto".format(
51+
prefix=self.descriptor.name[:-6], salt=str(uuid.uuid4())[0:8],
5052
)
5153

5254
# Add the file descriptor.
@@ -62,7 +64,7 @@ def generate_file_pb(self):
6264
pb_message = reflection.GeneratedProtocolMessageType(
6365
descriptor.name,
6466
(message.Message,),
65-
{'DESCRIPTOR': descriptor, '__module__': None},
67+
{"DESCRIPTOR": descriptor, "__module__": None},
6668
)
6769

6870
# Register the message with the marshal so it is wrapped
@@ -73,8 +75,7 @@ def generate_file_pb(self):
7375
# message subclass, which is what we need to use.
7476
proto_plus_message._meta._pb = pb_message
7577
proto_plus_message._meta.marshal.register(
76-
pb_message,
77-
MessageRule(pb_message, proto_plus_message)
78+
pb_message, MessageRule(pb_message, proto_plus_message)
7879
)
7980

8081
# Iterate over any fields on the message and, if their type
@@ -122,10 +123,8 @@ def ready(self, new_class):
122123
# manifest has been populated.
123124
module = inspect.getmodule(new_class)
124125
manifest = frozenset()
125-
if hasattr(module, '__protobuf__'):
126-
manifest = module.__protobuf__.manifest.difference(
127-
{new_class.__name__},
128-
)
126+
if hasattr(module, "__protobuf__"):
127+
manifest = module.__protobuf__.manifest.difference({new_class.__name__},)
129128
if not all([hasattr(module, i) for i in manifest]):
130129
return False
131130

packages/proto-plus/proto/_package_info.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ def compile(name, attrs):
3232
"""
3333
# Pull a reference to the module where this class is being
3434
# declared.
35-
module = sys.modules.get(attrs.get('__module__'))
36-
proto_module = getattr(module, '__protobuf__', object())
35+
module = sys.modules.get(attrs.get("__module__"))
36+
proto_module = getattr(module, "__protobuf__", object())
3737

3838
# A package should be present; get the marshal from there.
39-
package = getattr(proto_module, 'package', '')
40-
marshal = Marshal(name=getattr(proto_module, 'marshal', package))
39+
package = getattr(proto_module, "package", "")
40+
marshal = Marshal(name=getattr(proto_module, "marshal", package))
4141

4242
# Done; return the data.
4343
return (package, marshal)

packages/proto-plus/proto/enums.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
class ProtoEnumMeta(enum.EnumMeta):
2222
"""A metaclass for building and registering protobuf enums."""
23+
2324
def __new__(mcls, name, bases, attrs):
2425
# Do not do any special behavior for `proto.Enum` itself.
2526
if bases[0] == enum.IntEnum:
@@ -41,4 +42,5 @@ def __new__(mcls, name, bases, attrs):
4142

4243
class Enum(enum.IntEnum, metaclass=ProtoEnumMeta):
4344
"""A enum object that also builds a protobuf enum descriptor."""
45+
4446
pass

0 commit comments

Comments
 (0)