Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

Use Black to format Python code #6447

Merged
merged 7 commits into from
Feb 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
24 changes: 16 additions & 8 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
[flake8]
exclude = **/migrations/**,.tox,*.egg,vendor
# E501 - line too long (82 > 79 characters)
# E731 - do not assign a lambda expression, use a def
# F405 - name may be undefined, or defined from star imports: module
# W504 - line break after binary operator
# conflicts with W503 (line break before binary operator)
ignore = E501,E731,F405,W504
exclude = **/migrations/**

# Black recommends 88-char lines and ignoring the following lints:
# - E203 - whitespace before ':'
# - E501 - line too long
# - W503 - line break before binary operator
max-line-length=88
ignore = E203, E501, W503

# Allow star imports in config files:
per-file-ignores =
kuma/settings/local.py:F403,F405
kuma/settings/prod.py:F403,F405
kuma/settings/testing.py:F403,F405

# flake8-import-order settings
import-order-style=edited
application-import-names=kuma,pages,utils
application-import-names=kuma,pages,utils
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ matrix:
- poetry --version
- poetry install -vv
- poetry run flake8 kuma docs tests
- poetry run black --check kuma docs tests || echo "We're not letting it break things yet"
- poetry run black --check --diff kuma docs tests
- language: python
name: "Python testing"
python: 3.8
Expand Down
87 changes: 44 additions & 43 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,29 @@
extensions = []

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

# The suffix of source filenames.
source_suffix = '.rst'
source_suffix = ".rst"

# The encoding of source files.
# source_encoding = 'utf-8-sig'

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

# General information about the project.
project = 'Kuma'
copyright = 'Mozilla'
project = "Kuma"
copyright = "Mozilla"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = 'latest'
version = "latest"
# The full version, including alpha/beta/rc tags.
release = 'latest'
release = "latest"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand All @@ -64,7 +64,7 @@

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['_build']
exclude_patterns = ["_build"]

# The reST default role (used for this markup: `text`) to use for all documents.
# default_role = None
Expand Down Expand Up @@ -94,7 +94,7 @@

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

# Add any paths that contain custom themes here, relative to this directory.
html_theme_path = ["."]
Expand All @@ -103,26 +103,28 @@
# further. For a list of options available for each theme, see the
# documentation.
html_theme_options = {
'github_user': 'mozilla',
'github_repo': 'kuma',
'github_button': False,
'description': ('The platform that powers '
'<a href="https://developer.mozilla.org/en-US/">MDN</a>'),
'travis_button': False,
'codecov_button': False,
'extra_nav_links': {
'MDN': 'https://developer.mozilla.org',
'MDN Staging': 'https://developer.allizom.org',
'Kuma on GitHub': 'https://github.com/mdn/kuma',
'KumaScript on GitHub': 'https://github.com/mdn/kumascript',
"github_user": "mozilla",
"github_repo": "kuma",
"github_button": False,
"description": (
"The platform that powers "
'<a href="https://developer.mozilla.org/en-US/">MDN</a>'
),
"travis_button": False,
"codecov_button": False,
"extra_nav_links": {
"MDN": "https://developer.mozilla.org",
"MDN Staging": "https://developer.allizom.org",
"Kuma on GitHub": "https://github.com/mdn/kuma",
"KumaScript on GitHub": "https://github.com/mdn/kumascript",
},
'show_related': True,
'page_width': '100%'
"show_related": True,
"page_width": "100%",
}

# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
html_title = 'Kuma Documentation'
html_title = "Kuma Documentation"

# A shorter title for the navigation bar. Default is the same as html_title.
# html_short_title = None
Expand Down Expand Up @@ -151,12 +153,12 @@

# Custom sidebar templates, maps document names to template names.
html_sidebars = {
'**': [
'about.html',
'navigation.html',
'relations.html',
'searchbox.html',
'donate.html',
"**": [
"about.html",
"navigation.html",
"relations.html",
"searchbox.html",
"donate.html",
]
}

Expand Down Expand Up @@ -191,27 +193,24 @@
# html_file_suffix = None

# Output file base name for HTML help builder.
htmlhelp_basename = 'Kumadoc'
htmlhelp_basename = "Kumadoc"


# -- Options for LaTeX output --------------------------------------------------

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
# 'papersize': 'letterpaper',

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

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

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'Kuma.tex', 'Kuma Documentation',
'Mozilla', 'manual'),
("index", "Kuma.tex", "Kuma Documentation", "Mozilla", "manual"),
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -239,10 +238,7 @@

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'kuma', 'Kuma Documentation',
['Mozilla'], 1)
]
man_pages = [("index", "kuma", "Kuma Documentation", ["Mozilla"], 1)]

# If true, show URL addresses after external links.
# man_show_urls = False
Expand All @@ -254,10 +250,15 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'Kuma', 'Kuma Documentation',
'Mozilla', 'Kuma',
'The Django based project of developer.mozilla.org.',
'Miscellaneous'),
(
"index",
"Kuma",
"Kuma Documentation",
"Mozilla",
"Kuma",
"The Django based project of developer.mozilla.org.",
"Miscellaneous",
),
]

# Documents to append as an appendix to all manuals.
Expand Down
4 changes: 1 addition & 3 deletions kuma/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@


# This will make sure the app is always imported when
# Django starts so that shared_task will use this app.
from .celery import app as celery_app

__all__ = ('celery_app',)
__all__ = ("celery_app",)
5 changes: 3 additions & 2 deletions kuma/api/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ class APIConfig(AppConfig):
The Django App Config class to store information about the API app
and do startup time things.
"""
name = 'kuma.api'
verbose_name = 'API'

name = "kuma.api"
verbose_name = "API"

def ready(self):
"""Configure kuma.api after models are loaded."""
Expand Down
44 changes: 23 additions & 21 deletions kuma/api/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ def redirect_to_self(wiki_user):
"""
A top-level English document that redirects to itself.
"""
doc = Document.objects.create(
locale='en-US', slug='GoMe', title='Redirect to Self')
doc = Document.objects.create(locale="en-US", slug="GoMe", title="Redirect to Self")
Revision.objects.create(
document=doc,
creator=wiki_user,
content=REDIRECT_CONTENT % {
'href': reverse('wiki.document', locale=doc.locale,
args=(doc.slug,)),
'title': doc.title,
content=REDIRECT_CONTENT
% {
"href": reverse("wiki.document", locale=doc.locale, args=(doc.slug,)),
"title": doc.title,
},
title='Redirect to Self',
created=datetime(2018, 9, 16, 11, 15))
title="Redirect to Self",
created=datetime(2018, 9, 16, 11, 15),
)
return doc


Expand All @@ -33,16 +33,15 @@ def redirect_to_home(wiki_user):
A top-level English document that redirects to the home page.
"""
doc = Document.objects.create(
locale='en-US', slug='GoHome', title='Redirect to Home Page')
locale="en-US", slug="GoHome", title="Redirect to Home Page"
)
Revision.objects.create(
document=doc,
creator=wiki_user,
content=REDIRECT_CONTENT % {
'href': reverse('home'),
'title': 'MDN Web Docs',
},
title='Redirect to Home Page',
created=datetime(2015, 7, 4, 11, 15))
content=REDIRECT_CONTENT % {"href": reverse("home"), "title": "MDN Web Docs"},
title="Redirect to Home Page",
created=datetime(2015, 7, 4, 11, 15),
)
return doc


Expand All @@ -52,14 +51,17 @@ def redirect_to_macros(wiki_user):
A top-level English document that redirects to the macros dashboard.
"""
doc = Document.objects.create(
locale='en-US', slug='GoMacros', title='Redirect to Macros Dashboard')
locale="en-US", slug="GoMacros", title="Redirect to Macros Dashboard"
)
Revision.objects.create(
document=doc,
creator=wiki_user,
content=REDIRECT_CONTENT % {
'href': reverse('dashboards.macros', locale='en-US'),
'title': 'Active macros | MDN',
content=REDIRECT_CONTENT
% {
"href": reverse("dashboards.macros", locale="en-US"),
"title": "Active macros | MDN",
},
title='Redirect to Macros Dashboard',
created=datetime(2017, 5, 24, 12, 15))
title="Redirect to Macros Dashboard",
created=datetime(2017, 5, 24, 12, 15),
)
return doc