Skip to content

Ran black, updated to pylint 2.x #8

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 16, 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
40 changes: 26 additions & 14 deletions adafruit_pct2075.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,36 +50,44 @@
from adafruit_register.i2c_bits import RWBits
from adafruit_register.i2c_bit import RWBit
import adafruit_bus_device.i2c_device as i2cdevice

__version__ = "0.0.0-auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_PCT2075.git"
# pylint: disable=bad-whitespace, too-few-public-methods
PCT2075_DEFAULT_ADDRESS = 0x37 # Address is configured with pins A0-A2
PCT2075_DEFAULT_ADDRESS = 0x37 # Address is configured with pins A0-A2

PCT2075_REGISTER_TEMP = 0 # Temperature register (read-only)
PCT2075_REGISTER_CONFIG = 1 # Configuration register
PCT2075_REGISTER_THYST = 2 # Hysterisis register
PCT2075_REGISTER_TOS = 3 # OS register
PCT2075_REGISTER_TIDLE = 4 # Measurement idle time register

PCT2075_REGISTER_TEMP = 0 # Temperature register (read-only)
PCT2075_REGISTER_CONFIG = 1 # Configuration register
PCT2075_REGISTER_THYST = 2 # Hysterisis register
PCT2075_REGISTER_TOS = 3 # OS register
PCT2075_REGISTER_TIDLE = 4 # Measurement idle time register

class Mode:
"""Options for `mode`"""

INTERRUPT = 1
COMPARITOR = 0


class FaultCount:
"""Options for `faults_to_alert`"""

FAULT_1 = 0
FAULT_2 = 1
FAULT_4 = 2
FAULT_6 = 3


# pylint: enable=bad-whitespace, too-few-public-methods


class PCT2075:
"""Driver for the PCT2075 Digital Temperature Sensor and Thermal Watchdog.
:param ~busio.I2C i2c_bus: The I2C bus the INA260 is connected to.
:param address: The I2C device address for the sensor. Default is ``0x37``.
"""

def __init__(self, i2c_bus, address=PCT2075_DEFAULT_ADDRESS):
self.i2c_device = i2cdevice.I2CDevice(i2c_bus, address)

Expand Down Expand Up @@ -107,7 +115,7 @@ def __init__(self, i2c_bus, address=PCT2075_DEFAULT_ADDRESS):
@property
def temperature(self):
"""Returns the current temperature in degress celsius. Resolution is 0.125 degrees C"""
return (self._temperature>>5) * 0.125
return (self._temperature >> 5) * 0.125

@property
def high_temperature_threshold(self):
Expand All @@ -117,21 +125,23 @@ def high_temperature_threshold(self):

@high_temperature_threshold.setter
def high_temperature_threshold(self, value):
self._high_temperature_threshold = (int(value * 2) << 7)
self._high_temperature_threshold = int(value * 2) << 7

@property
def temperature_hysteresis(self):
"""The temperature hysteresis value defines the bottom of the temperature range in degrees
C in which the temperature is still considered high". `temperature_hysteresis` must be
lower than `high_temperature_threshold`. Resolution is 0.5 degrees C.
"""
return (self._temp_hysteresis >> 7) * 0.5
return (self._temp_hysteresis >> 7) * 0.5

@temperature_hysteresis.setter
def temperature_hysteresis(self, value):
if value >= self.high_temperature_threshold:
raise ValueError("temperature_hysteresis must be less than high_temperature_threshold")
self._temp_hysteresis = (int(value * 2) << 7)
raise ValueError(
"temperature_hysteresis must be less than high_temperature_threshold"
)
self._temp_hysteresis = int(value * 2) << 7

@property
def faults_to_alert(self):
Expand All @@ -158,6 +168,8 @@ def delay_between_measurements(self):
@delay_between_measurements.setter
def delay_between_measurements(self, value):
if value > 3100 or value < 100 or value % 100 > 0:
raise AttributeError(""""delay_between_measurements must be >= 100 or <= 3100\
and a multiple of 100""")
self._idle_time = int(value/100)
raise AttributeError(
""""delay_between_measurements must be >= 100 or <= 3100\
and a multiple of 100"""
)
self._idle_time = int(value / 100)
120 changes: 73 additions & 47 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,29 +24,40 @@
autodoc_mock_imports = ["adafruit_register", "adafruit_bus_device"]


intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'BusDevice': ('https://circuitpython.readthedocs.io/projects/busdevice/en/latest/', None),'Register': ('https://circuitpython.readthedocs.io/projects/register/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,
),
"Register": (
"https://circuitpython.readthedocs.io/projects/register/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 PCT2075 Library'
copyright = u'2019 Bryan Siepert'
author = u'Bryan Siepert'
project = u"Adafruit PCT2075 Library"
copyright = u"2019 Bryan Siepert"
author = u"Bryan Siepert"

# 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 +69,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 +81,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 +96,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 = 'AdafruitPct2075Librarydoc'
htmlhelp_basename = "AdafruitPct2075Librarydoc"

# -- 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, 'AdafruitPCT2075Library.tex', u'AdafruitPCT2075 Library Documentation',
author, 'manual'),
(
master_doc,
"AdafruitPCT2075Library.tex",
u"AdafruitPCT2075 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, 'AdafruitPCT2075library', u'Adafruit PCT2075 Library Documentation',
[author], 1)
(
master_doc,
"AdafruitPCT2075library",
u"Adafruit PCT2075 Library Documentation",
[author],
1,
)
]

# -- Options for Texinfo output -------------------------------------------
Expand All @@ -154,7 +174,13 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'AdafruitPCT2075Library', u'Adafruit PCT2075 Library Documentation',
author, 'AdafruitPCT2075Library', 'One line description of project.',
'Miscellaneous'),
(
master_doc,
"AdafruitPCT2075Library",
u"Adafruit PCT2075 Library Documentation",
author,
"AdafruitPCT2075Library",
"One line description of project.",
"Miscellaneous",
),
]
4 changes: 2 additions & 2 deletions examples/pct2075_high_temp_alert_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
pct.high_temperature_threshold = 35.5
pct.temperature_hysteresis = 30.0
pct.high_temp_active_high = False
print("High temp alert active high? %s"%pct.high_temp_active_high)
print("High temp alert active high? %s" % pct.high_temp_active_high)

# Attach an LED with the Cathode to the INT pin and Anode to 3.3V with a current limiting resistor

while True:
print("Temperature: %.2f C"%pct.temperature)
print("Temperature: %.2f C" % pct.temperature)
time.sleep(0.5)
3 changes: 2 additions & 1 deletion examples/pct2075_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
import board
import busio
import adafruit_pct2075

i2c = busio.I2C(board.SCL, board.SDA)

pct = adafruit_pct2075.PCT2075(i2c)

while True:
print("Temperature: %.2f C"%pct.temperature)
print("Temperature: %.2f C" % pct.temperature)
time.sleep(0.5)
Loading