Skip to content

pylint to precommit #5

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 4 commits into from
Mar 3, 2021
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
9 changes: 2 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,9 @@ jobs:
pip install --force-reinstall pylint Sphinx sphinx-rtd-theme pre-commit
- name: Library version
run: git describe --dirty --always --tags
# disable because it's failing on not being able to find a 'latest'
#- name: Pre-commit hooks
# run: |
# pre-commit run --all-files
- name: PyLint
- name: Pre-commit hooks
run: |
pylint $( find . -path './adafruit*.py' )
([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name,bad-whitespace $( find . -path "./examples/*.py" ))
pre-commit run --all-files
- name: Build assets
run: circuitpython-build-bundles --filename_prefix ${{ steps.repo-name.outputs.repo-name }} --library_location .
- name: Build docs
Expand Down
19 changes: 17 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

repos:
- repo: https://github.com/python/black
rev: latest
rev: 20.8b1
hooks:
- id: black
- repo: https://github.com/fsfe/reuse-tool
rev: latest
rev: v0.12.1
hooks:
- id: reuse
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand All @@ -17,3 +17,18 @@ repos:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/pycqa/pylint
rev: pylint-2.7.1
hooks:
- id: pylint
name: pylint (library code)
types: [python]
exclude: "^(docs/|examples/|setup.py$)"
- repo: local
hooks:
- id: pylint_examples
name: pylint (examples code)
description: Run pylint rules on "examples/*.py" files
entry: /usr/bin/env bash -c
args: ['([[ ! -d "examples" ]] || for example in $(find . -path "./examples/*.py"); do pylint --disable=missing-docstring,invalid-name $example; done)']
language: system
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ ignore-comments=yes
ignore-docstrings=yes

# Ignore imports when computing similarities.
ignore-imports=no
ignore-imports=yes

# Minimum lines number of a similarity.
min-similarity-lines=4
Expand Down
48 changes: 21 additions & 27 deletions adafruit_emc2101.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,7 @@ def __str__(self):
lut_keys.sort()
for temp in lut_keys:
fan_drive = self.lut_values[temp]
value_strs.append("%d deg C => %.1f%% duty cycle" %
(temp, fan_drive))
value_strs.append("%d deg C => %.1f%% duty cycle" % (temp, fan_drive))

return "\n".join(value_strs)

Expand All @@ -176,8 +175,7 @@ def _set_lut(self, lut_dict):
# Verify that the value is a correct amount
lut_value = lut_dict[k]
if lut_value > 100.0 or lut_value < 0:
raise AttributeError(
"LUT values must be a fan speed from 0-100%")
raise AttributeError("LUT values must be a fan speed from 0-100%")

# add the current temp/speed to our internal representation
self.lut_values[k] = lut_value
Expand All @@ -192,20 +190,16 @@ def _set_lut(self, lut_dict):
for idx in range(lut_size):
current_temp = lut_keys[idx]
current_speed = _speed_to_lsb(self.lut_values[current_temp])
getattr(self, "_fan_lut_t%d" %
(idx + 1)).__set__(self, current_temp)
getattr(self, "_fan_lut_s%d" %
(idx + 1)).__set__(self, current_speed)
getattr(self, "_fan_lut_t%d" % (idx + 1)).__set__(self, current_temp)
getattr(self, "_fan_lut_s%d" % (idx + 1)).__set__(self, current_speed)

# self.emc_fan._lut_temp_setters[idx].__set__(self.emc_fan, current_temp)
# self.emc_fan._lut_speed_setters[idx].__set__(self.emc_fan, current_speed)

# Set the remaining LUT entries to the default (Temp/Speed = max value)
for idx in range(8)[lut_size:]:
getattr(self, "_fan_lut_t%d" %
(idx + 1)).__set__(self, MAX_LUT_TEMP)
getattr(self, "_fan_lut_s%d" %
(idx + 1)).__set__(self, MAX_LUT_SPEED)
getattr(self, "_fan_lut_t%d" % (idx + 1)).__set__(self, MAX_LUT_TEMP)
getattr(self, "_fan_lut_s%d" % (idx + 1)).__set__(self, MAX_LUT_SPEED)
self.emc_fan.lut_enabled = current_mode


Expand Down Expand Up @@ -284,7 +278,7 @@ class SpinupTime(CV):

class EMC2101: # pylint: disable=too-many-instance-attributes
"""Driver for the EMC2101 Fan Controller.
:param ~busio.I2C i2c_bus: The I2C bus the EMC is connected to.
:param ~busio.I2C i2c_bus: The I2C bus the EMC is connected to.
"""

_part_id = ROUnaryStruct(_REG_PARTID, "<B")
Expand Down Expand Up @@ -372,19 +366,19 @@ def external_temperature(self):

def set_pwm_clock(self, use_preset=False, use_slow=False):
"""
Select the PWM clock source, chosing between two preset clocks or by configuring the
clock using `pwm_frequency` and `pwm_frequency_divisor`.

:param bool use_preset:
True: Select between two preset clock sources
False: The PWM clock is set by `pwm_frequency` and `pwm_frequency_divisor`
:param bool use_slow:
True: Use the 1.4kHz clock
False: Use the 360kHz clock.
:type priority: integer or None
:return: None
:raises AttributeError: if use_preset is not a `bool`
:raises AttributeError: if use_slow is not a `bool`
Select the PWM clock source, chosing between two preset clocks or by configuring the
clock using `pwm_frequency` and `pwm_frequency_divisor`.

:param bool use_preset:
True: Select between two preset clock sources
False: The PWM clock is set by `pwm_frequency` and `pwm_frequency_divisor`
:param bool use_slow:
True: Use the 1.4kHz clock
False: Use the 360kHz clock.
:type priority: integer or None
:return: None
:raises AttributeError: if use_preset is not a `bool`
:raises AttributeError: if use_slow is not a `bool`

"""

Expand Down Expand Up @@ -450,7 +444,7 @@ def manual_fan_speed(self, fan_speed):
@property
def lut_enabled(self):
"""Enable or disable the internal look up table used to map a given temperature
to a fan speed. When the LUT is disabled, fan speed can be changed with `manual_fan_speed`"""
to a fan speed. When the LUT is disabled fan speed can be changed with `manual_fan_speed`"""
return not self._fan_lut_prog

@lut_enabled.setter
Expand Down