Skip to content

Commit 3ae2a7c

Browse files
authored
Merge pull request #5 from FoamyGuy/pylint_to_precommit
pylint to precommit
2 parents c495e12 + 16923e6 commit 3ae2a7c

File tree

4 files changed

+41
-37
lines changed

4 files changed

+41
-37
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,9 @@ jobs:
4747
pip install --force-reinstall pylint Sphinx sphinx-rtd-theme pre-commit
4848
- name: Library version
4949
run: git describe --dirty --always --tags
50-
# disable because it's failing on not being able to find a 'latest'
51-
#- name: Pre-commit hooks
52-
# run: |
53-
# pre-commit run --all-files
54-
- name: PyLint
50+
- name: Pre-commit hooks
5551
run: |
56-
pylint $( find . -path './adafruit*.py' )
57-
([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name,bad-whitespace $( find . -path "./examples/*.py" ))
52+
pre-commit run --all-files
5853
- name: Build assets
5954
run: circuitpython-build-bundles --filename_prefix ${{ steps.repo-name.outputs.repo-name }} --library_location .
6055
- name: Build docs

.pre-commit-config.yaml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
repos:
66
- repo: https://github.com/python/black
7-
rev: latest
7+
rev: 20.8b1
88
hooks:
99
- id: black
1010
- repo: https://github.com/fsfe/reuse-tool
11-
rev: latest
11+
rev: v0.12.1
1212
hooks:
1313
- id: reuse
1414
- repo: https://github.com/pre-commit/pre-commit-hooks
@@ -17,3 +17,18 @@ repos:
1717
- id: check-yaml
1818
- id: end-of-file-fixer
1919
- id: trailing-whitespace
20+
- repo: https://github.com/pycqa/pylint
21+
rev: pylint-2.7.1
22+
hooks:
23+
- id: pylint
24+
name: pylint (library code)
25+
types: [python]
26+
exclude: "^(docs/|examples/|setup.py$)"
27+
- repo: local
28+
hooks:
29+
- id: pylint_examples
30+
name: pylint (examples code)
31+
description: Run pylint rules on "examples/*.py" files
32+
entry: /usr/bin/env bash -c
33+
args: ['([[ ! -d "examples" ]] || for example in $(find . -path "./examples/*.py"); do pylint --disable=missing-docstring,invalid-name $example; done)']
34+
language: system

.pylintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ ignore-comments=yes
250250
ignore-docstrings=yes
251251

252252
# Ignore imports when computing similarities.
253-
ignore-imports=no
253+
ignore-imports=yes
254254

255255
# Minimum lines number of a similarity.
256256
min-similarity-lines=4

adafruit_emc2101.py

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,7 @@ def __str__(self):
152152
lut_keys.sort()
153153
for temp in lut_keys:
154154
fan_drive = self.lut_values[temp]
155-
value_strs.append("%d deg C => %.1f%% duty cycle" %
156-
(temp, fan_drive))
155+
value_strs.append("%d deg C => %.1f%% duty cycle" % (temp, fan_drive))
157156

158157
return "\n".join(value_strs)
159158

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

182180
# add the current temp/speed to our internal representation
183181
self.lut_values[k] = lut_value
@@ -192,20 +190,16 @@ def _set_lut(self, lut_dict):
192190
for idx in range(lut_size):
193191
current_temp = lut_keys[idx]
194192
current_speed = _speed_to_lsb(self.lut_values[current_temp])
195-
getattr(self, "_fan_lut_t%d" %
196-
(idx + 1)).__set__(self, current_temp)
197-
getattr(self, "_fan_lut_s%d" %
198-
(idx + 1)).__set__(self, current_speed)
193+
getattr(self, "_fan_lut_t%d" % (idx + 1)).__set__(self, current_temp)
194+
getattr(self, "_fan_lut_s%d" % (idx + 1)).__set__(self, current_speed)
199195

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

203199
# Set the remaining LUT entries to the default (Temp/Speed = max value)
204200
for idx in range(8)[lut_size:]:
205-
getattr(self, "_fan_lut_t%d" %
206-
(idx + 1)).__set__(self, MAX_LUT_TEMP)
207-
getattr(self, "_fan_lut_s%d" %
208-
(idx + 1)).__set__(self, MAX_LUT_SPEED)
201+
getattr(self, "_fan_lut_t%d" % (idx + 1)).__set__(self, MAX_LUT_TEMP)
202+
getattr(self, "_fan_lut_s%d" % (idx + 1)).__set__(self, MAX_LUT_SPEED)
209203
self.emc_fan.lut_enabled = current_mode
210204

211205

@@ -284,7 +278,7 @@ class SpinupTime(CV):
284278

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

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

373367
def set_pwm_clock(self, use_preset=False, use_slow=False):
374368
"""
375-
Select the PWM clock source, chosing between two preset clocks or by configuring the
376-
clock using `pwm_frequency` and `pwm_frequency_divisor`.
377-
378-
:param bool use_preset:
379-
True: Select between two preset clock sources
380-
False: The PWM clock is set by `pwm_frequency` and `pwm_frequency_divisor`
381-
:param bool use_slow:
382-
True: Use the 1.4kHz clock
383-
False: Use the 360kHz clock.
384-
:type priority: integer or None
385-
:return: None
386-
:raises AttributeError: if use_preset is not a `bool`
387-
:raises AttributeError: if use_slow is not a `bool`
369+
Select the PWM clock source, chosing between two preset clocks or by configuring the
370+
clock using `pwm_frequency` and `pwm_frequency_divisor`.
371+
372+
:param bool use_preset:
373+
True: Select between two preset clock sources
374+
False: The PWM clock is set by `pwm_frequency` and `pwm_frequency_divisor`
375+
:param bool use_slow:
376+
True: Use the 1.4kHz clock
377+
False: Use the 360kHz clock.
378+
:type priority: integer or None
379+
:return: None
380+
:raises AttributeError: if use_preset is not a `bool`
381+
:raises AttributeError: if use_slow is not a `bool`
388382
389383
"""
390384

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

456450
@lut_enabled.setter

0 commit comments

Comments
 (0)