Skip to content

Commit 54d42f1

Browse files
authored
Merge pull request #44 from adafruit/pylint-update
Ran black, updated to pylint 2.x
2 parents 7d7ad89 + efcff1b commit 54d42f1

File tree

7 files changed

+185
-155
lines changed

7 files changed

+185
-155
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
source actions-ci/install.sh
4141
- name: Pip install pylint, black, & Sphinx
4242
run: |
43-
pip install --force-reinstall pylint==1.9.2 black==19.10b0 Sphinx sphinx-rtd-theme
43+
pip install --force-reinstall pylint black==19.10b0 Sphinx sphinx-rtd-theme
4444
- name: Library version
4545
run: git describe --dirty --always --tags
4646
- name: PyLint

.pylintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ spelling-store-unknown-words=no
119119
[MISCELLANEOUS]
120120

121121
# List of note tags to take in consideration, separated by a comma.
122-
notes=FIXME,XXX,TODO
122+
# notes=FIXME,XXX,TODO
123+
notes=FIXME,XXX
123124

124125

125126
[TYPECHECK]

adafruit_bno055.py

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
__version__ = "0.0.0-auto.0"
4040
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_BNO055.git"
4141

42-
_CHIP_ID = const(0xa0)
42+
_CHIP_ID = const(0xA0)
4343

4444
CONFIG_MODE = const(0x00)
4545
ACCONLY_MODE = const(0x01)
@@ -51,31 +51,30 @@
5151
AMG_MODE = const(0x07)
5252
IMUPLUS_MODE = const(0x08)
5353
COMPASS_MODE = const(0x09)
54-
M4G_MODE = const(0x0a)
55-
NDOF_FMC_OFF_MODE = const(0x0b)
56-
NDOF_MODE = const(0x0c)
54+
M4G_MODE = const(0x0A)
55+
NDOF_FMC_OFF_MODE = const(0x0B)
56+
NDOF_MODE = const(0x0C)
5757

5858
_POWER_NORMAL = const(0x00)
5959
_POWER_LOW = const(0x01)
6060
_POWER_SUSPEND = const(0x02)
6161

62-
_MODE_REGISTER = const(0x3d)
62+
_MODE_REGISTER = const(0x3D)
6363
_PAGE_REGISTER = const(0x07)
6464
_CALIBRATION_REGISTER = const(0x35)
6565
_OFFSET_ACCEL_REGISTER = const(0x55)
66-
_OFFSET_MAGNET_REGISTER = const(0x5b)
66+
_OFFSET_MAGNET_REGISTER = const(0x5B)
6767
_OFFSET_GYRO_REGISTER = const(0x61)
6868
_RADIUS_ACCEL_REGISTER = const(0x67)
6969
_RADIUS_MAGNET_REGISTER = const(0x69)
70-
_TRIGGER_REGISTER = const(0x3f)
71-
_POWER_REGISTER = const(0x3e)
70+
_TRIGGER_REGISTER = const(0x3F)
71+
_POWER_REGISTER = const(0x3E)
7272
_ID_REGISTER = const(0x00)
7373

7474

75-
class _ScaledReadOnlyStruct(Struct): # pylint: disable=too-few-public-methods
75+
class _ScaledReadOnlyStruct(Struct): # pylint: disable=too-few-public-methods
7676
def __init__(self, register_address, struct_format, scale):
77-
super(_ScaledReadOnlyStruct, self).__init__(
78-
register_address, struct_format)
77+
super(_ScaledReadOnlyStruct, self).__init__(register_address, struct_format)
7978
self.scale = scale
8079

8180
def __get__(self, obj, objtype=None):
@@ -86,11 +85,12 @@ def __set__(self, obj, value):
8685
raise NotImplementedError()
8786

8887

89-
class _ReadOnlyUnaryStruct(UnaryStruct): # pylint: disable=too-few-public-methods
88+
class _ReadOnlyUnaryStruct(UnaryStruct): # pylint: disable=too-few-public-methods
9089
def __set__(self, obj, value):
9190
raise NotImplementedError()
9291

93-
class _ModeStruct(Struct): # pylint: disable=too-few-public-methods
92+
93+
class _ModeStruct(Struct): # pylint: disable=too-few-public-methods
9494
def __init__(self, register_address, struct_format, mode):
9595
super().__init__(register_address, struct_format)
9696
self.mode = mode
@@ -111,31 +111,31 @@ def __set__(self, obj, value):
111111
super().__set__(obj, set_val)
112112
obj.mode = last_mode
113113

114+
114115
class BNO055:
115116
"""
116117
Driver for the BNO055 9DOF IMU sensor.
117118
"""
118119

119-
_temperature = _ReadOnlyUnaryStruct(0x34, 'b')
120-
_acceleration = _ScaledReadOnlyStruct(0x08, '<hhh', 1/100)
121-
_magnetic = _ScaledReadOnlyStruct(0x0e, '<hhh', 1/16)
122-
_gyro = _ScaledReadOnlyStruct(0x14, '<hhh', 0.001090830782496456)
123-
_euler = _ScaledReadOnlyStruct(0x1a, '<hhh', 1/16)
124-
_quaternion = _ScaledReadOnlyStruct(0x20, '<hhhh', 1/(1<<14))
125-
_linear_acceleration = _ScaledReadOnlyStruct(0x28, '<hhh', 1/100)
126-
_gravity = _ScaledReadOnlyStruct(0x2e, '<hhh', 1/100)
120+
_temperature = _ReadOnlyUnaryStruct(0x34, "b")
121+
_acceleration = _ScaledReadOnlyStruct(0x08, "<hhh", 1 / 100)
122+
_magnetic = _ScaledReadOnlyStruct(0x0E, "<hhh", 1 / 16)
123+
_gyro = _ScaledReadOnlyStruct(0x14, "<hhh", 0.001090830782496456)
124+
_euler = _ScaledReadOnlyStruct(0x1A, "<hhh", 1 / 16)
125+
_quaternion = _ScaledReadOnlyStruct(0x20, "<hhhh", 1 / (1 << 14))
126+
_linear_acceleration = _ScaledReadOnlyStruct(0x28, "<hhh", 1 / 100)
127+
_gravity = _ScaledReadOnlyStruct(0x2E, "<hhh", 1 / 100)
127128

128-
129-
offsets_accelerometer = _ModeStruct(_OFFSET_ACCEL_REGISTER, '<hhh', CONFIG_MODE)
129+
offsets_accelerometer = _ModeStruct(_OFFSET_ACCEL_REGISTER, "<hhh", CONFIG_MODE)
130130
"""Calibration offsets for the accelerometer"""
131-
offsets_magnetometer = _ModeStruct(_OFFSET_MAGNET_REGISTER, '<hhh', CONFIG_MODE)
131+
offsets_magnetometer = _ModeStruct(_OFFSET_MAGNET_REGISTER, "<hhh", CONFIG_MODE)
132132
"""Calibration offsets for the magnetometer"""
133-
offsets_gyroscope = _ModeStruct(_OFFSET_GYRO_REGISTER, '<hhh', CONFIG_MODE)
133+
offsets_gyroscope = _ModeStruct(_OFFSET_GYRO_REGISTER, "<hhh", CONFIG_MODE)
134134
"""Calibration offsets for the gyroscope"""
135135

136-
radius_accelerometer = _ModeStruct(_RADIUS_ACCEL_REGISTER, '<h', CONFIG_MODE)
136+
radius_accelerometer = _ModeStruct(_RADIUS_ACCEL_REGISTER, "<h", CONFIG_MODE)
137137
"""Radius for accelerometer (cm?)"""
138-
radius_magnetometer = _ModeStruct(_RADIUS_MAGNET_REGISTER, '<h', CONFIG_MODE)
138+
radius_magnetometer = _ModeStruct(_RADIUS_MAGNET_REGISTER, "<h", CONFIG_MODE)
139139
"""Radius for magnetometer (cm?)"""
140140

141141
def __init__(self, i2c, address=0x28):
@@ -161,16 +161,15 @@ def _write_register(self, register, value):
161161
def _read_register(self, register):
162162
self.buffer[0] = register
163163
with self.i2c_device as i2c:
164-
i2c.write_then_readinto(self.buffer, self.buffer,
165-
out_end=1, in_start=1)
164+
i2c.write_then_readinto(self.buffer, self.buffer, out_end=1, in_start=1)
166165
return self.buffer[1]
167166

168167
def _reset(self):
169168
"""Resets the sensor to default settings."""
170169
self.mode = CONFIG_MODE
171170
try:
172171
self._write_register(_TRIGGER_REGISTER, 0x20)
173-
except OSError: # error due to the chip resetting
172+
except OSError: # error due to the chip resetting
174173
pass
175174
# wait for the chip to reset (650 ms typ.)
176175
time.sleep(0.7)
@@ -262,7 +261,6 @@ def use_external_crystal(self, value):
262261
self.mode = last_mode
263262
time.sleep(0.01)
264263

265-
266264
@property
267265
def temperature(self):
268266
"""Measures the temperature of the chip in degrees Celsius."""
@@ -291,7 +289,7 @@ def gyro(self):
291289
"""Gives the raw gyroscope reading in radians per second.
292290
Returns an empty tuple of length 3 when this property has been disabled by the current mode.
293291
"""
294-
if self.mode not in [0x00, 0x01, 0x02, 0x04, 0x09, 0x0a]:
292+
if self.mode not in [0x00, 0x01, 0x02, 0x04, 0x09, 0x0A]:
295293
return self._gyro
296294
return (None, None, None)
297295

@@ -300,7 +298,7 @@ def euler(self):
300298
"""Gives the calculated orientation angles, in degrees.
301299
Returns an empty tuple of length 3 when this property has been disabled by the current mode.
302300
"""
303-
if self.mode in [0x09, 0x0b, 0x0c]:
301+
if self.mode in [0x09, 0x0B, 0x0C]:
304302
return self._euler
305303
return (None, None, None)
306304

@@ -309,7 +307,7 @@ def quaternion(self):
309307
"""Gives the calculated orientation as a quaternion.
310308
Returns an empty tuple of length 3 when this property has been disabled by the current mode.
311309
"""
312-
if self.mode in [0x09, 0x0b, 0x0c]:
310+
if self.mode in [0x09, 0x0B, 0x0C]:
313311
return self._quaternion
314312
return (None, None, None, None)
315313

@@ -318,7 +316,7 @@ def linear_acceleration(self):
318316
"""Returns the linear acceleration, without gravity, in m/s.
319317
Returns an empty tuple of length 3 when this property has been disabled by the current mode.
320318
"""
321-
if self.mode in [0x09, 0x0b, 0x0c]:
319+
if self.mode in [0x09, 0x0B, 0x0C]:
322320
return self._linear_acceleration
323321
return (None, None, None)
324322

@@ -327,6 +325,6 @@ def gravity(self):
327325
"""Returns the gravity vector, without acceleration in m/s.
328326
Returns an empty tuple of length 3 when this property has been disabled by the current mode.
329327
"""
330-
if self.mode in [0x09, 0x0b, 0x0c]:
328+
if self.mode in [0x09, 0x0B, 0x0C]:
331329
return self._gravity
332330
return (None, None, None)

0 commit comments

Comments
 (0)