Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforcing black #67

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,6 @@ man/

# pytest
.pytest_cache

#vscode
.vscode/
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
repos:
- repo: https://github.com/ambv/black
rev: stable
hooks:
- id: black
language_version: python3.7
56 changes: 26 additions & 30 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@

# -- Project information -----------------------------------------------------

project = 'Flask-Rebar'
copyright = '2018, Barak Alon'
author = 'Barak Alon'
project = "Flask-Rebar"
copyright = "2018, Barak Alon"
author = "Barak Alon"

# The short X.Y version
version = ''
version = ""
# The full version, including alpha/beta/rc tags
release = ''
release = ""


# -- General configuration ---------------------------------------------------
Expand All @@ -38,24 +38,21 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.autosectionlabel'
]
extensions = ["sphinx.ext.autodoc", "sphinx.ext.autosectionlabel"]

autodoc_member_order = 'bysource'
autodoc_member_order = "bysource"


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

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
source_suffix = ['.rst']
source_suffix = [".rst"]

# The master toctree document.
master_doc = 'index'
master_doc = "index"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand All @@ -67,18 +64,18 @@
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path .
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = "sphinx"


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'
html_theme = "sphinx_rtd_theme"

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
Expand All @@ -89,7 +86,7 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]

# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
Expand All @@ -105,7 +102,7 @@
# -- Options for HTMLHelp output ---------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'Flask-Rebardoc'
htmlhelp_basename = "Flask-Rebardoc"


# -- Options for LaTeX output ------------------------------------------------
Expand All @@ -114,15 +111,12 @@
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',

# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
Expand All @@ -132,19 +126,15 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'Flask-Rebar.tex', 'Flask-Rebar Documentation',
'Barak Alon', 'manual'),
(master_doc, "Flask-Rebar.tex", "Flask-Rebar Documentation", "Barak Alon", "manual")
]


# -- Options for manual page output ------------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'flask-rebar', 'Flask-Rebar Documentation',
[author], 1)
]
man_pages = [(master_doc, "flask-rebar", "Flask-Rebar Documentation", [author], 1)]


# -- Options for Texinfo output ----------------------------------------------
Expand All @@ -153,9 +143,15 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'Flask-Rebar', 'Flask-Rebar Documentation',
author, 'Flask-Rebar', 'One line description of project.',
'Miscellaneous'),
(
master_doc,
"Flask-Rebar",
"Flask-Rebar Documentation",
author,
"Flask-Rebar",
"One line description of project.",
"Miscellaneous",
)
]


Expand Down
88 changes: 44 additions & 44 deletions examples/todo/generate_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@


this_directory = os.path.dirname(os.path.realpath(__file__))
todo_app_filepath = os.path.join(this_directory, 'todo.py')
todo_output_filepath = os.path.join(this_directory, 'todo_output.md')
todo_app_filepath = os.path.join(this_directory, "todo.py")
todo_output_filepath = os.path.join(this_directory, "todo_output.md")


@contextlib.contextmanager
def app():
print('Starting app...')
print("Starting app...")

app_process = None
try:
app_process = subprocess.Popen(
args=['python', todo_app_filepath],
args=["python", todo_app_filepath],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
Expand All @@ -26,8 +26,7 @@ def app():
while not up:
try:
subprocess.check_output(
'curl -s http://127.0.0.1:5000/swagger',
shell=True
"curl -s http://127.0.0.1:5000/swagger", shell=True
)
up = True
except subprocess.SubprocessError:
Expand All @@ -44,57 +43,58 @@ def main():
output = []

with app():
output.extend([
'# cURL and examples/todo.py',
"Here's a snippet of playing with the application inside todo.py.",
'',
])
output.extend(
[
"# cURL and examples/todo.py",
"Here's a snippet of playing with the application inside todo.py.",
"",
]
)

for title, commands in [
('Swagger for free!', [
"curl -s -XGET http://127.0.0.1:5000/swagger"
]),
('Request validation!', [
'curl -s -XPATCH http://127.0.0.1:5000/todos/1 -H "X-MyApp-Key: my-api-key" -H "Content-Type: application/json" -d \'{"complete": "wrong type, for demonstration of validation"}\''
]),
('Authentication!', [
"curl -s -XGET http://127.0.0.1:5000/todos",
'curl -s -XGET http://127.0.0.1:5000/todos -H "X-MyApp-Key: my-api-key"'
]),
('CRUD!', [
'curl -s -XPOST http://127.0.0.1:5000/todos -H "X-MyApp-Key: my-api-key" -H "Content-Type: application/json" -d \'{"complete": false, "description": "Find product market fit"}\'',
'curl -s -XPATCH http://127.0.0.1:5000/todos/1 -H "X-MyApp-Key: my-api-key" -H "Content-Type: application/json" -d \'{"complete": true}\'',
'curl -s -XGET http://127.0.0.1:5000/todos -H "X-MyApp-Key: my-api-key"'
])

("Swagger for free!", ["curl -s -XGET http://127.0.0.1:5000/swagger"]),
(
"Request validation!",
[
'curl -s -XPATCH http://127.0.0.1:5000/todos/1 -H "X-MyApp-Key: my-api-key" -H "Content-Type: application/json" -d \'{"complete": "wrong type, for demonstration of validation"}\''
],
),
(
"Authentication!",
[
"curl -s -XGET http://127.0.0.1:5000/todos",
'curl -s -XGET http://127.0.0.1:5000/todos -H "X-MyApp-Key: my-api-key"',
],
),
(
"CRUD!",
[
'curl -s -XPOST http://127.0.0.1:5000/todos -H "X-MyApp-Key: my-api-key" -H "Content-Type: application/json" -d \'{"complete": false, "description": "Find product market fit"}\'',
'curl -s -XPATCH http://127.0.0.1:5000/todos/1 -H "X-MyApp-Key: my-api-key" -H "Content-Type: application/json" -d \'{"complete": true}\'',
'curl -s -XGET http://127.0.0.1:5000/todos -H "X-MyApp-Key: my-api-key"',
],
),
]:
output.extend([
title,
'```',
])
output.extend([title, "```"])

for command in commands:
print(command)

result = subprocess.check_output(command, shell=True)

output.extend([
'$ ' + command,
json.dumps(json.loads(result), indent=2),
])
output.extend(
["$ " + command, json.dumps(json.loads(result), indent=2)]
)

output.extend([
'```',
'',
])
output.extend(["```", ""])

print('Writing output to {}'.format(todo_output_filepath))
print("Writing output to {}".format(todo_output_filepath))

with open(todo_output_filepath, 'w') as f:
f.write('\n'.join(output))
with open(todo_output_filepath, "w") as f:
f.write("\n".join(output))

print('Done!')
print("Done!")


if __name__ == '__main__':
if __name__ == "__main__":
main()
Loading