diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c8c2a90..0434bc5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fbda35c..354c761 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 @@ -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 diff --git a/.pylintrc b/.pylintrc index 54a9d35..3c07cc6 100644 --- a/.pylintrc +++ b/.pylintrc @@ -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 diff --git a/adafruit_emc2101.py b/adafruit_emc2101.py index 1c1f9b4..3ed3002 100644 --- a/adafruit_emc2101.py +++ b/adafruit_emc2101.py @@ -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) @@ -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 @@ -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 @@ -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, "