Skip to content

Ran black, updated to pylint 2.x #27

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

Merged
merged 1 commit into from
Mar 17, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
source actions-ci/install.sh
- name: Pip install pylint, black, & Sphinx
run: |
pip install --force-reinstall pylint==1.9.2 black==19.10b0 Sphinx sphinx-rtd-theme
pip install --force-reinstall pylint black==19.10b0 Sphinx sphinx-rtd-theme
- name: Library version
run: git describe --dirty --always --tags
- name: PyLint
Expand Down
57 changes: 40 additions & 17 deletions adafruit_crickit.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@

from micropython import const

#pylint: disable=wrong-import-position
# pylint: disable=wrong-import-position
try:
lib_index = sys.path.index("/lib") # pylint: disable=invalid-name
lib_index = sys.path.index("/lib") # pylint: disable=invalid-name
if lib_index < sys.path.index(".frozen"):
# Prefer frozen modules over those in /lib.
sys.path.insert(lib_index, ".frozen")
Expand Down Expand Up @@ -95,9 +95,10 @@
_NEOPIXEL = const(20)
_SS_PIXEL = const(27)

#pylint: disable=too-few-public-methods
# pylint: disable=too-few-public-methods
class CrickitTouchIn:
"""Imitate touchio.TouchIn."""

def __init__(self, seesaw, pin):
self._seesaw = seesaw
self._pin = pin
Expand All @@ -114,7 +115,7 @@ def value(self):
return self.raw_value > self.threshold


#pylint: disable=too-many-public-methods
# pylint: disable=too-many-public-methods
class Crickit:
"""Represents a Crickit board. Provides a number of devices available via properties, such as
``servo_1``. Devices are created on demand the first time they are referenced.
Expand Down Expand Up @@ -260,7 +261,9 @@ def feather_drive_stepper_motor(self):
def _motor(self, terminals, motor_class):
device = self._devices.get(terminals, None)
if not isinstance(device, motor_class):
device = motor_class(*(PWMOut(self._seesaw, terminal) for terminal in terminals))
device = motor_class(
*(PWMOut(self._seesaw, terminal) for terminal in terminals)
)
self._devices[terminals] = device
return device

Expand Down Expand Up @@ -345,8 +348,9 @@ def neopixel(self):
raise ValueError("Call init_neopixel first")
return self._neopixel


def init_neopixel(self, n, *, bpp=3, brightness=1.0, auto_write=True, pixel_order=None):
def init_neopixel(
self, n, *, bpp=3, brightness=1.0, auto_write=True, pixel_order=None
):
"""Set up a seesaw.NeoPixel object

.. note:: On the CPX Crickit board, the NeoPixel terminal is by default
Expand All @@ -366,31 +370,50 @@ def init_neopixel(self, n, *, bpp=3, brightness=1.0, auto_write=True, pixel_orde
crickit.init_neopixel(24)
crickit.neopixel.fill((100, 0, 0))
"""
from adafruit_seesaw.neopixel import NeoPixel
self._neopixel = NeoPixel(self._seesaw, _NEOPIXEL, n, bpp=bpp,
brightness=brightness, auto_write=auto_write,
pixel_order=pixel_order)
from adafruit_seesaw.neopixel import ( # pylint: disable=import-outside-toplevel
NeoPixel,
)

self._neopixel = NeoPixel(
self._seesaw,
_NEOPIXEL,
n,
bpp=bpp,
brightness=brightness,
auto_write=auto_write,
pixel_order=pixel_order,
)

@property
def onboard_pixel(self):
"""```adafruit_seesaw.neopixel`` object on the Seesaw on-board NeoPixel.
Initialize on-board NeoPixel and clear upon first use.
"""
if not self._onboard_pixel:
from adafruit_seesaw.neopixel import NeoPixel
self._onboard_pixel = NeoPixel(self._seesaw, _SS_PIXEL, 1, bpp=3,
brightness=1.0, auto_write=True,
pixel_order=None)
from adafruit_seesaw.neopixel import ( # pylint: disable=import-outside-toplevel
NeoPixel,
)

self._onboard_pixel = NeoPixel(
self._seesaw,
_SS_PIXEL,
1,
bpp=3,
brightness=1.0,
auto_write=True,
pixel_order=None,
)
self._onboard_pixel.fill((0, 0, 0))
return self._onboard_pixel

def reset(self):
"""Reset the whole Crickit board."""
self._seesaw.sw_reset()

crickit = None # pylint: disable=invalid-name

crickit = None # pylint: disable=invalid-name
"""A singleton instance to control a single Crickit board, controlled by the default I2C pins."""

# Sphinx's board is missing real pins so skip the constructor in that case.
if "I2C" in dir(board):
crickit = Crickit(Seesaw(board.I2C())) # pylint: disable=invalid-name
crickit = Crickit(Seesaw(board.I2C())) # pylint: disable=invalid-name
121 changes: 72 additions & 49 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@

import os
import sys
sys.path.insert(0, os.path.abspath('..'))

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

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

# 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.intersphinx',
'sphinx.ext.napoleon',
'sphinx.ext.todo',
"sphinx.ext.autodoc",
"sphinx.ext.intersphinx",
"sphinx.ext.napoleon",
"sphinx.ext.todo",
]


Expand All @@ -23,33 +24,41 @@
# autodoc_mock_imports = ["digitalio", "busio"]


intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),
'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}
intersphinx_mapping = {
"python": ("https://docs.python.org/3.4", None),
"CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None),
}

# Libraries we depend on but don't need for generating docs.
autodoc_mock_imports = ['board', 'busio', 'micropython', 'adafruit_seesaw', 'adafruit_motor']
autodoc_mock_imports = [
"board",
"busio",
"micropython",
"adafruit_seesaw",
"adafruit_motor",
]

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

source_suffix = '.rst'
source_suffix = ".rst"

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

# General information about the project.
project = u'Adafruit Crickit Library'
copyright = u'2018 Dan Halbert'
author = u'Dan Halbert'
project = u"Adafruit Crickit Library"
copyright = u"2018 Dan Halbert"
author = u"Dan Halbert"

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

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand All @@ -61,7 +70,7 @@
# 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', '.env', 'CODE_OF_CONDUCT.md']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".env", "CODE_OF_CONDUCT.md"]

# The reST default role (used for this markup: `text`) to use for all
# documents.
Expand All @@ -73,7 +82,7 @@
add_function_parentheses = True

# 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 = False
Expand All @@ -88,68 +97,76 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
on_rtd = os.environ.get("READTHEDOCS", None) == "True"

if not on_rtd: # only import and set the theme if we're building docs locally
try:
import sphinx_rtd_theme
html_theme = 'sphinx_rtd_theme'
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), '.']

html_theme = "sphinx_rtd_theme"
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."]
except:
html_theme = 'default'
html_theme_path = ['.']
html_theme = "default"
html_theme_path = ["."]
else:
html_theme_path = ['.']
html_theme_path = ["."]

# 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"]

# The name of an image file (relative to this directory) to use as a favicon of
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#
html_favicon = '_static/favicon.ico'
html_favicon = "_static/favicon.ico"

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

# -- 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': '',

# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
# 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',
}

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'AdafruitCrickitLibrary.tex', u'AdafruitCrickit Library Documentation',
author, 'manual'),
(
master_doc,
"AdafruitCrickitLibrary.tex",
u"AdafruitCrickit Library Documentation",
author,
"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, 'AdafruitCrickitLibrary', u'Adafruit Crickit Library Documentation',
[author], 1)
(
master_doc,
"AdafruitCrickitLibrary",
u"Adafruit Crickit Library Documentation",
[author],
1,
)
]

# -- Options for Texinfo output -------------------------------------------
Expand All @@ -158,7 +175,13 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'AdafruitCrickitLibrary', u'Adafruit Crickit Library Documentation',
author, 'AdafruitCrickitLibrary', 'One line description of project.',
'Miscellaneous'),
(
master_doc,
"AdafruitCrickitLibrary",
u"Adafruit Crickit Library Documentation",
author,
"AdafruitCrickitLibrary",
"One line description of project.",
"Miscellaneous",
),
]
2 changes: 1 addition & 1 deletion examples/crickit_drive_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# For Circuit Playground Express, micro:bit, and RPi Crickit, use:
drive_1 = crickit.drive_1
# For Feather Crickit, use:
#drive_1 = crickit.feather_drive_1
# drive_1 = crickit.feather_drive_1

# Turn on Drive 1 for 1 second and then off for 1 second
while True:
Expand Down
Loading