From 53dab2b7ba785cf93129f9de5448df989605edf6 Mon Sep 17 00:00:00 2001 From: dherrada Date: Mon, 9 Mar 2020 19:29:05 -0400 Subject: [PATCH] Ran black, updated to pylint 2.x --- .github/workflows/build.yml | 2 +- adafruit_ssd1327.py | 30 +++++---- docs/conf.py | 112 +++++++++++++++++++-------------- examples/ssd1327_gamma.py | 7 ++- examples/ssd1327_simpletest.py | 5 +- 5 files changed, 92 insertions(+), 64 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fff3aa9..97fe64d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 pylint black==19.10b0 Sphinx sphinx-rtd-theme - name: Library version run: git describe --dirty --always --tags - name: PyLint diff --git a/adafruit_ssd1327.py b/adafruit_ssd1327.py index f6e921f..7084b01 100644 --- a/adafruit_ssd1327.py +++ b/adafruit_ssd1327.py @@ -49,12 +49,12 @@ __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_SSD1327.git" _INIT_SEQUENCE = ( - b"\xAE\x00" # DISPLAY_OFF - b"\x81\x01\x80" # set contrast control - b"\xa0\x01\x53" # remap memory, odd even columns, com flip and column swap - b"\xa1\x01\x00" # Display start line is 0 - b"\xa2\x01\x00" # Display offset is 0 - b"\xa4\x00" # Normal display + b"\xAE\x00" # DISPLAY_OFF + b"\x81\x01\x80" # set contrast control + b"\xa0\x01\x53" # remap memory, odd even columns, com flip and column swap + b"\xa1\x01\x00" # Display start line is 0 + b"\xa2\x01\x00" # Display offset is 0 + b"\xa4\x00" # Normal display b"\xa8\x01\x3f" # Mux ratio is 1/64 b"\xb1\x01\x11" # Set phase length b"\xb8\x0f\x00\x01\x02\x03\x04\x05\x06\x07\x08\x10\x18\x20\x2f\x38\x3f" # Set graytable @@ -71,15 +71,23 @@ # pylint: disable=too-few-public-methods class SSD1327(displayio.Display): """SSD1327 driver""" + def __init__(self, bus, **kwargs): # Patch the init sequence for 32 pixel high displays. init_sequence = bytearray(_INIT_SEQUENCE) height = kwargs["height"] if "rotation" in kwargs and kwargs["rotation"] % 180 != 0: height = kwargs["width"] - init_sequence[18] = height - 1 # patch mux ratio + init_sequence[18] = height - 1 # patch mux ratio print(height) - super().__init__(bus, init_sequence, **kwargs, color_depth=4, grayscale=True, - set_column_command=0x15, set_row_command=0x75, - data_as_commands=True, - single_byte_bounds=True) + super().__init__( + bus, + init_sequence, + **kwargs, + color_depth=4, + grayscale=True, + set_column_command=0x15, + set_row_command=0x75, + data_as_commands=True, + single_byte_bounds=True, + ) diff --git a/docs/conf.py b/docs/conf.py index 2a8767a..252950b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -2,7 +2,8 @@ import os import sys -sys.path.insert(0, os.path.abspath('..')) + +sys.path.insert(0, os.path.abspath("..")) # -- General configuration ------------------------------------------------ @@ -10,10 +11,10 @@ # 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", ] # TODO: Please Read! @@ -23,29 +24,32 @@ autodoc_mock_imports = ["displayio"] -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), +} # 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 SSD1327 Library' -copyright = u'2019 Scott Shawcroft' -author = u'Scott Shawcroft' +project = "Adafruit SSD1327 Library" +copyright = "2019 Scott Shawcroft" +author = "Scott Shawcroft" # 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 = "1.0" # The full version, including alpha/beta/rc tags. -release = u'1.0' +release = "1.0" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -57,7 +61,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. @@ -69,7 +73,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 @@ -84,59 +88,62 @@ # 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 = 'AdafruitSsd1327Librarydoc' +htmlhelp_basename = "AdafruitSsd1327Librarydoc" # -- 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, 'AdafruitSSD1327Library.tex', u'AdafruitSSD1327 Library Documentation', - author, 'manual'), + ( + master_doc, + "AdafruitSSD1327Library.tex", + "AdafruitSSD1327 Library Documentation", + author, + "manual", + ), ] # -- Options for manual page output --------------------------------------- @@ -144,8 +151,13 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - (master_doc, 'AdafruitSSD1327library', u'Adafruit SSD1327 Library Documentation', - [author], 1) + ( + master_doc, + "AdafruitSSD1327library", + "Adafruit SSD1327 Library Documentation", + [author], + 1, + ) ] # -- Options for Texinfo output ------------------------------------------- @@ -154,7 +166,13 @@ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - (master_doc, 'AdafruitSSD1327Library', u'Adafruit SSD1327 Library Documentation', - author, 'AdafruitSSD1327Library', 'One line description of project.', - 'Miscellaneous'), + ( + master_doc, + "AdafruitSSD1327Library", + "Adafruit SSD1327 Library Documentation", + author, + "AdafruitSSD1327Library", + "One line description of project.", + "Miscellaneous", + ), ] diff --git a/examples/ssd1327_gamma.py b/examples/ssd1327_gamma.py index 917ad7b..4af4f27 100644 --- a/examples/ssd1327_gamma.py +++ b/examples/ssd1327_gamma.py @@ -12,8 +12,9 @@ tft_dc = board.D9 tft_reset = board.D5 -display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs, reset=tft_reset, - baudrate=1000000) +display_bus = displayio.FourWire( + spi, command=tft_dc, chip_select=tft_cs, reset=tft_reset, baudrate=1000000 +) time.sleep(1) display = adafruit_ssd1327.SSD1327(display_bus, width=128, height=128) @@ -29,7 +30,7 @@ for i in range(dimension): if i % pixels_per_step == 0: continue - gamma_pattern[i,i] = i // pixels_per_step + gamma_pattern[i, i] = i // pixels_per_step for i in range(color_count): component = i * 255 // (color_count - 1) diff --git a/examples/ssd1327_simpletest.py b/examples/ssd1327_simpletest.py index 543ad70..01b0d34 100644 --- a/examples/ssd1327_simpletest.py +++ b/examples/ssd1327_simpletest.py @@ -12,7 +12,8 @@ tft_dc = board.D9 tft_reset = board.D5 -display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs, reset=tft_reset, - baudrate=1000000) +display_bus = displayio.FourWire( + spi, command=tft_dc, chip_select=tft_cs, reset=tft_reset, baudrate=1000000 +) time.sleep(1) display = adafruit_ssd1327.SSD1327(display_bus, width=128, height=128)