Skip to content

Commit

Permalink
Merge pull request #25 from adafruit/pylint-update
Browse files Browse the repository at this point in the history
Ran black, updated to pylint 2.x
  • Loading branch information
FoamyGuy authored Mar 17, 2020
2 parents 2745057 + 63b161b commit 7049c1c
Show file tree
Hide file tree
Showing 10 changed files with 156 additions and 136 deletions.
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
13 changes: 8 additions & 5 deletions adafruit_mcp230xx/digital_inout.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@
def _get_bit(val, bit):
return val & (1 << bit) > 0


def _enable_bit(val, bit):
return val | (1 << bit)


def _clear_bit(val, bit):
return val & ~(1 << bit)

Expand All @@ -63,7 +65,7 @@ def __init__(self, pin_number, mcp230xx):
# with DigitalInout class (which allows specifying pull, etc. which
# is unused by this class). Do not remove them, instead turn off pylint
# in this case.
#pylint: disable=unused-argument
# pylint: disable=unused-argument
def switch_to_output(self, value=False, **kwargs):
"""Switch the pin state to a digital output with the provided starting
value (True/False for high or low, default is False/low).
Expand All @@ -78,7 +80,8 @@ def switch_to_input(self, pull=None, **kwargs):
"""
self.direction = digitalio.Direction.INPUT
self.pull = pull
#pylint: enable=unused-argument

# pylint: enable=unused-argument

@property
def value(self):
Expand Down Expand Up @@ -111,7 +114,7 @@ def direction(self, val):
elif val == digitalio.Direction.OUTPUT:
self._mcp.iodir = _clear_bit(self._mcp.iodir, self._pin)
else:
raise ValueError('Expected INPUT or OUTPUT direction!')
raise ValueError("Expected INPUT or OUTPUT direction!")

@property
def pull(self):
Expand All @@ -130,6 +133,6 @@ def pull(self, val):
elif val == digitalio.Pull.UP:
self._mcp.gppu = _enable_bit(self._mcp.gppu, self._pin)
elif val == digitalio.Pull.DOWN:
raise ValueError('Pull-down resistors are not supported!')
raise ValueError("Pull-down resistors are not supported!")
else:
raise ValueError('Expected UP, DOWN, or None for pull state!')
raise ValueError("Expected UP, DOWN, or None for pull state!")
24 changes: 12 additions & 12 deletions adafruit_mcp230xx/mcp23008.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_MCP230xx.git"

# pylint: disable=bad-whitespace
_MCP23008_ADDRESS = const(0x20)
_MCP23008_IODIR = const(0x00)
_MCP23008_IPOL = const(0x01)
_MCP23008_GPINTEN = const(0x02)
_MCP23008_DEFVAL = const(0x03)
_MCP23008_INTCON = const(0x04)
_MCP23008_IOCON = const(0x05)
_MCP23008_GPPU = const(0x06)
_MCP23008_INTF = const(0x07)
_MCP23008_INTCAP = const(0x08)
_MCP23008_GPIO = const(0x09)
_MCP23008_ADDRESS = const(0x20)
_MCP23008_IODIR = const(0x00)
_MCP23008_IPOL = const(0x01)
_MCP23008_GPINTEN = const(0x02)
_MCP23008_DEFVAL = const(0x03)
_MCP23008_INTCON = const(0x04)
_MCP23008_IOCON = const(0x05)
_MCP23008_GPPU = const(0x06)
_MCP23008_INTF = const(0x07)
_MCP23008_INTCAP = const(0x08)
_MCP23008_GPIO = const(0x09)


class MCP23008(MCP230XX):
Expand All @@ -60,7 +60,7 @@ def __init__(self, i2c, address=_MCP23008_ADDRESS):

# Reset to all inputs with no pull-ups and no inverted polarity.
self.iodir = 0xFF
self.gppu = 0x00
self.gppu = 0x00
self._write_u8(_MCP23008_IPOL, 0x00)

@property
Expand Down
36 changes: 18 additions & 18 deletions adafruit_mcp230xx/mcp23017.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,22 @@
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_MCP230xx.git"

# pylint: disable=bad-whitespace
_MCP23017_ADDRESS = const(0x20)
_MCP23017_IODIRA = const(0x00)
_MCP23017_IODIRB = const(0x01)
_MCP23017_IPOLA = const(0x02)
_MCP23017_GPINTENA = const(0x04)
_MCP23017_DEFVALA = const(0x06)
_MCP23017_INTCONA = const(0x08)
_MCP23017_IOCON = const(0x0A)
_MCP23017_GPPUA = const(0x0C)
_MCP23017_GPPUB = const(0x0D)
_MCP23017_GPIOA = const(0x12)
_MCP23017_GPIOB = const(0x13)
_MCP23017_INTFA = const(0x0E)
_MCP23017_INTFB = const(0x0F)
_MCP23017_INTCAPA = const(0x10)
_MCP23017_INTCAPB = const(0x11)
_MCP23017_ADDRESS = const(0x20)
_MCP23017_IODIRA = const(0x00)
_MCP23017_IODIRB = const(0x01)
_MCP23017_IPOLA = const(0x02)
_MCP23017_GPINTENA = const(0x04)
_MCP23017_DEFVALA = const(0x06)
_MCP23017_INTCONA = const(0x08)
_MCP23017_IOCON = const(0x0A)
_MCP23017_GPPUA = const(0x0C)
_MCP23017_GPPUB = const(0x0D)
_MCP23017_GPIOA = const(0x12)
_MCP23017_GPIOB = const(0x13)
_MCP23017_INTFA = const(0x0E)
_MCP23017_INTFB = const(0x0F)
_MCP23017_INTCAPA = const(0x10)
_MCP23017_INTCAPB = const(0x11)


class MCP23017(MCP230XX):
Expand All @@ -65,7 +65,7 @@ def __init__(self, i2c, address=_MCP23017_ADDRESS):
# Reset to all inputs with no pull-ups and no inverted polarity.
self.iodir = 0xFFFF
self.gppu = 0x0000
self.iocon = 0x4 # turn on IRQ Pins as open drain
self.iocon = 0x4 # turn on IRQ Pins as open drain
self._write_u16le(_MCP23017_IPOLA, 0x0000)

@property
Expand Down Expand Up @@ -263,7 +263,7 @@ def int_flagb(self):
pins: 8-15
"""
intfb = self._read_u8(_MCP23017_INTFB)
flags = [pin+8 for pin in range(8) if intfb & (1 << pin)]
flags = [pin + 8 for pin in range(8) if intfb & (1 << pin)]
return flags

def clear_ints(self):
Expand Down
114 changes: 68 additions & 46 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.autodoc",
"sphinx.ext.intersphinx",
#'sphinx.ext.napoleon'
'sphinx.ext.todo',
"sphinx.ext.todo",
]

# TODO: Please Read!
Expand All @@ -23,29 +24,36 @@
autodoc_mock_imports = ["micropython", "adafruit_bus_device", "digitalio"]


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

# 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 MCP230xx Library'
copyright = u'2017 Tony DiCola'
author = u'Tony DiCola'
project = u"Adafruit MCP230xx Library"
copyright = u"2017 Tony DiCola"
author = u"Tony DiCola"

# 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 @@ -57,7 +65,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 @@ -69,7 +77,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 @@ -84,68 +92,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 = 'AdafruitMcp230xxLibrarydoc'
htmlhelp_basename = "AdafruitMcp230xxLibrarydoc"

# -- 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, 'AdafruitMCP230xxLibrary.tex', u'AdafruitMCP230xx Library Documentation',
author, 'manual'),
(
master_doc,
"AdafruitMCP230xxLibrary.tex",
u"AdafruitMCP230xx 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, 'AdafruitMCP230xxlibrary', u'Adafruit MCP230xx Library Documentation',
[author], 1)
(
master_doc,
"AdafruitMCP230xxlibrary",
u"Adafruit MCP230xx Library Documentation",
[author],
1,
)
]

# -- Options for Texinfo output -------------------------------------------
Expand All @@ -154,7 +170,13 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'AdafruitMCP230xxLibrary', u'Adafruit MCP230xx Library Documentation',
author, 'AdafruitMCP230xxLibrary', 'One line description of project.',
'Miscellaneous'),
(
master_doc,
"AdafruitMCP230xxLibrary",
u"Adafruit MCP230xx Library Documentation",
author,
"AdafruitMCP230xxLibrary",
"One line description of project.",
"Miscellaneous",
),
]
Loading

0 comments on commit 7049c1c

Please sign in to comment.