Skip to content

Commit

Permalink
Use black for source code formatting. Add precommit hook to make it s…
Browse files Browse the repository at this point in the history
…imple to use. (#559)
  • Loading branch information
rytilahti authored Oct 10, 2019
1 parent d4354e3 commit 276fb38
Show file tree
Hide file tree
Showing 65 changed files with 3,635 additions and 3,139 deletions.
3 changes: 3 additions & 0 deletions .flake8.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[flake8]
exclude = .git,.tox,__pycache__
max-line-length = 100
select = C,E,F,W,B,B950
ignore = E501,W503,E203

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
93 changes: 47 additions & 46 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
#
import os
import sys
sys.path.insert(0, os.path.abspath('..'))

sys.path.insert(0, os.path.abspath(".."))

# -- General configuration ------------------------------------------------

Expand All @@ -31,40 +32,41 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx_autodoc_typehints',
'sphinx.ext.todo',
'sphinx.ext.coverage',
'sphinx.ext.viewcode',
'sphinx.ext.githubpages',
'sphinx.ext.intersphinx',
'sphinx_click.ext']
"sphinx.ext.autodoc",
"sphinx_autodoc_typehints",
"sphinx.ext.todo",
"sphinx.ext.coverage",
"sphinx.ext.viewcode",
"sphinx.ext.githubpages",
"sphinx.ext.intersphinx",
"sphinx_click.ext",
]

# 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', '.md']
source_suffix = '.rst'
source_suffix = ".rst"

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

# General information about the project.
project = 'python-miio'
copyright = '2017, Teemu Rytilahti'
author = 'Teemu Rytilahti'
project = "python-miio"
copyright = "2017, Teemu Rytilahti"
author = "Teemu Rytilahti"

# 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 = ''
version = ""
# The full version, including alpha/beta/rc tags.
release = ''
release = ""

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

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

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True
Expand All @@ -95,7 +92,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"

# 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 @@ -114,20 +111,20 @@
# This is required for the alabaster theme
# refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars
html_sidebars = {
'**': [
'about.html',
'navigation.html',
'relations.html', # needs 'show_related': True theme option to display
'searchbox.html',
'donate.html',
"**": [
"about.html",
"navigation.html",
"relations.html", # needs 'show_related': True theme option to display
"searchbox.html",
"donate.html",
]
}


# -- Options for HTMLHelp output ------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'python-miiodoc'
htmlhelp_basename = "python-miiodoc"


# -- Options for LaTeX output ---------------------------------------------
Expand All @@ -136,15 +133,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 @@ -154,19 +148,21 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'python-miio.tex', 'python-miio Documentation',
'Teemu Rytilahti', 'manual'),
(
master_doc,
"python-miio.tex",
"python-miio Documentation",
"Teemu Rytilahti",
"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, 'python-miio', 'python-miio Documentation',
[author], 1)
]
man_pages = [(master_doc, "python-miio", "python-miio Documentation", [author], 1)]


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

intersphinx_mapping = {'python': ('https://docs.python.org/3.6', None)}

intersphinx_mapping = {"python": ("https://docs.python.org/3.6", None)}
10 changes: 8 additions & 2 deletions miio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,14 @@
from miio.toiletlid import Toiletlid
from miio.pwzn_relay import PwznRelay
from miio.vacuum import Vacuum, VacuumException
from miio.vacuumcontainers import (VacuumStatus, ConsumableStatus, DNDStatus,
CleaningDetails, CleaningSummary, Timer, )
from miio.vacuumcontainers import (
VacuumStatus,
ConsumableStatus,
DNDStatus,
CleaningDetails,
CleaningSummary,
Timer,
)
from miio.waterpurifier import WaterPurifier
from miio.wifirepeater import WifiRepeater
from miio.wifispeaker import WifiSpeaker
Expand Down
Loading

0 comments on commit 276fb38

Please sign in to comment.