Browse Source

module: add pylint and fix accordingly

cn 8 months ago
parent
commit
f9b9d77ded
6 changed files with 632 additions and 65 deletions
  1. 560
    0
      .pylintrc
  2. 1
    0
      .travis.yml
  3. 5
    5
      bme280/__init__.py
  4. 57
    54
      bme280/bme280.py
  5. 8
    6
      demo.py
  6. 1
    0
      requirements.txt

+ 560
- 0
.pylintrc View File

@@ -0,0 +1,560 @@
1
+[MASTER]
2
+
3
+# A comma-separated list of package or module names from where C extensions may
4
+# be loaded. Extensions are loading into the active Python interpreter and may
5
+# run arbitrary code
6
+extension-pkg-whitelist=
7
+
8
+# Add files or directories to the blacklist. They should be base names, not
9
+# paths.
10
+ignore=CVS
11
+
12
+# Add files or directories matching the regex patterns to the blacklist. The
13
+# regex matches against base names, not paths.
14
+ignore-patterns=.*_test.py,setup.py
15
+
16
+# Python code to execute, usually for sys.path manipulation such as
17
+# pygtk.require().
18
+#init-hook=
19
+
20
+# Use multiple processes to speed up Pylint.
21
+jobs=1
22
+
23
+# List of plugins (as comma separated values of python modules names) to load,
24
+# usually to register additional checkers.
25
+load-plugins=
26
+
27
+# Pickle collected data for later comparisons.
28
+persistent=no
29
+
30
+# Specify a configuration file.
31
+#rcfile=
32
+
33
+# When enabled, pylint would attempt to guess common misconfiguration and emit
34
+# user-friendly hints instead of false-positive error messages
35
+suggestion-mode=yes
36
+
37
+# Allow loading of arbitrary C extensions. Extensions are imported into the
38
+# active Python interpreter and may run arbitrary code.
39
+unsafe-load-any-extension=no
40
+
41
+
42
+[MESSAGES CONTROL]
43
+
44
+# Only show warnings with the listed confidence levels. Leave empty to show
45
+# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED
46
+confidence=
47
+
48
+# Disable the message, report, category or checker with the given id(s). You
49
+# can either give multiple identifiers separated by comma (,) or put this
50
+# option multiple times (only on the command line, not in the configuration
51
+# file where it should appear only once).You can also use "--disable=all" to
52
+# disable everything first and then reenable specific checks. For example, if
53
+# you want to run only the similarities checker, you can use "--disable=all
54
+# --enable=similarities". If you want to run only the classes checker, but have
55
+# no Warning level messages displayed, use"--disable=all --enable=classes
56
+# --disable=W"
57
+disable=print-statement,
58
+        parameter-unpacking,
59
+        unpacking-in-except,
60
+        old-raise-syntax,
61
+        backtick,
62
+        long-suffix,
63
+        old-ne-operator,
64
+        old-octal-literal,
65
+        import-star-module-level,
66
+        non-ascii-bytes-literal,
67
+        raw-checker-failed,
68
+        bad-inline-option,
69
+        locally-disabled,
70
+        locally-enabled,
71
+        file-ignored,
72
+        suppressed-message,
73
+        useless-suppression,
74
+        deprecated-pragma,
75
+        apply-builtin,
76
+        basestring-builtin,
77
+        buffer-builtin,
78
+        cmp-builtin,
79
+        coerce-builtin,
80
+        execfile-builtin,
81
+        file-builtin,
82
+        long-builtin,
83
+        raw_input-builtin,
84
+        reduce-builtin,
85
+        standarderror-builtin,
86
+        unicode-builtin,
87
+        xrange-builtin,
88
+        coerce-method,
89
+        delslice-method,
90
+        getslice-method,
91
+        setslice-method,
92
+        no-absolute-import,
93
+        old-division,
94
+        dict-iter-method,
95
+        dict-view-method,
96
+        next-method-called,
97
+        metaclass-assignment,
98
+        indexing-exception,
99
+        raising-string,
100
+        reload-builtin,
101
+        oct-method,
102
+        hex-method,
103
+        nonzero-method,
104
+        cmp-method,
105
+        input-builtin,
106
+        round-builtin,
107
+        intern-builtin,
108
+        unichr-builtin,
109
+        map-builtin-not-iterating,
110
+        zip-builtin-not-iterating,
111
+        range-builtin-not-iterating,
112
+        filter-builtin-not-iterating,
113
+        using-cmp-argument,
114
+        eq-without-hash,
115
+        div-method,
116
+        idiv-method,
117
+        rdiv-method,
118
+        exception-message-attribute,
119
+        invalid-str-codec,
120
+        sys-max-int,
121
+        bad-python3-import,
122
+        deprecated-string-function,
123
+        deprecated-str-translate-call,
124
+        deprecated-itertools-function,
125
+        deprecated-types-field,
126
+        next-method-defined,
127
+        dict-items-not-iterating,
128
+        dict-keys-not-iterating,
129
+        dict-values-not-iterating,
130
+        missing-docstring,
131
+        line-too-long,
132
+        c-extension-no-member,
133
+        no-self-use
134
+
135
+# Enable the message, report, category or checker with the given id(s). You can
136
+# either give multiple identifier separated by comma (,) or put this option
137
+# multiple time (only on the command line, not in the configuration file where
138
+# it should appear only once). See also the "--disable" option for examples.
139
+enable=
140
+
141
+
142
+[REPORTS]
143
+
144
+# Python expression which should return a note less than 10 (10 is the highest
145
+# note). You have access to the variables errors warning, statement which
146
+# respectively contain the number of errors / warnings messages and the total
147
+# number of statements analyzed. This is used by the global evaluation report
148
+# (RP0004).
149
+evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
150
+
151
+# Template used to display messages. This is a python new-style format string
152
+# used to format the message information. See doc for all details
153
+#msg-template=
154
+
155
+# Set the output format. Available formats are text, parseable, colorized, json
156
+# and msvs (visual studio).You can also give a reporter class, eg
157
+# mypackage.mymodule.MyReporterClass.
158
+output-format=colorized
159
+
160
+# Tells whether to display a full report or only the messages
161
+reports=no
162
+
163
+# Activate the evaluation score.
164
+score=yes
165
+
166
+
167
+[REFACTORING]
168
+
169
+# Maximum number of nested blocks for function / method body
170
+max-nested-blocks=5
171
+
172
+# Complete name of functions that never returns. When checking for
173
+# inconsistent-return-statements if a never returning function is called then
174
+# it will be considered as an explicit return statement and no message will be
175
+# printed.
176
+never-returning-functions=optparse.Values,sys.exit
177
+
178
+
179
+[BASIC]
180
+
181
+# Naming style matching correct argument names
182
+argument-naming-style=snake_case
183
+
184
+# Regular expression matching correct argument names. Overrides argument-
185
+# naming-style
186
+#argument-rgx=
187
+
188
+# Naming style matching correct attribute names
189
+attr-naming-style=snake_case
190
+
191
+# Regular expression matching correct attribute names. Overrides attr-naming-
192
+# style
193
+#attr-rgx=
194
+
195
+# Bad variable names which should always be refused, separated by a comma
196
+bad-names=foo,
197
+          bar,
198
+          baz,
199
+          toto,
200
+          tutu,
201
+          tata
202
+
203
+# Naming style matching correct class attribute names
204
+class-attribute-naming-style=any
205
+
206
+# Regular expression matching correct class attribute names. Overrides class-
207
+# attribute-naming-style
208
+#class-attribute-rgx=
209
+
210
+# Naming style matching correct class names
211
+class-naming-style=PascalCase
212
+
213
+# Regular expression matching correct class names. Overrides class-naming-style
214
+#class-rgx=
215
+
216
+# Naming style matching correct constant names
217
+const-naming-style=UPPER_CASE
218
+
219
+# Regular expression matching correct constant names. Overrides const-naming-
220
+# style
221
+#const-rgx=
222
+
223
+# Minimum line length for functions/classes that require docstrings, shorter
224
+# ones are exempt.
225
+docstring-min-length=-1
226
+
227
+# Naming style matching correct function names
228
+function-naming-style=snake_case
229
+
230
+# Regular expression matching correct function names. Overrides function-
231
+# naming-style
232
+#function-rgx=
233
+
234
+# Good variable names which should always be accepted, separated by a comma
235
+good-names=i,
236
+           j,
237
+           k,
238
+           ex,
239
+           Run,
240
+           _,
241
+           ho,
242
+           po,
243
+           to,
244
+           t,
245
+           p,
246
+           h,
247
+           digT,
248
+           digP,
249
+           digH,
250
+           adc_T,
251
+           adc_P,
252
+           adc_H,
253
+           var_H,
254
+           is_status_image_register_updating
255
+
256
+# Include a hint for the correct naming format with invalid-name
257
+include-naming-hint=no
258
+
259
+# Naming style matching correct inline iteration names
260
+inlinevar-naming-style=any
261
+
262
+# Regular expression matching correct inline iteration names. Overrides
263
+# inlinevar-naming-style
264
+#inlinevar-rgx=
265
+
266
+# Naming style matching correct method names
267
+method-naming-style=snake_case
268
+
269
+# Regular expression matching correct method names. Overrides method-naming-
270
+# style
271
+#method-rgx=
272
+
273
+# Naming style matching correct module names
274
+module-naming-style=snake_case
275
+
276
+# Regular expression matching correct module names. Overrides module-naming-
277
+# style
278
+#module-rgx=
279
+
280
+# Colon-delimited sets of names that determine each other's naming style when
281
+# the name regexes allow several styles.
282
+name-group=
283
+
284
+# Regular expression which should only match function or class names that do
285
+# not require a docstring.
286
+no-docstring-rgx=^_
287
+
288
+# List of decorators that produce properties, such as abc.abstractproperty. Add
289
+# to this list to register other decorators that produce valid properties.
290
+property-classes=abc.abstractproperty
291
+
292
+# Naming style matching correct variable names
293
+variable-naming-style=snake_case
294
+
295
+# Regular expression matching correct variable names. Overrides variable-
296
+# naming-style
297
+#variable-rgx=
298
+
299
+
300
+[FORMAT]
301
+
302
+# Expected format of line ending, e.g. empty (any line ending), LF or CRLF.
303
+expected-line-ending-format=
304
+
305
+# Regexp for a line that is allowed to be longer than the limit.
306
+ignore-long-lines=^\s*(# )?<?https?://\S+>?$
307
+
308
+# Number of spaces of indent required inside a hanging  or continued line.
309
+indent-after-paren=4
310
+
311
+# String used as indentation unit. This is usually "    " (4 spaces) or "\t" (1
312
+# tab).
313
+indent-string='    '
314
+
315
+# Maximum number of characters on a single line.
316
+max-line-length=100
317
+
318
+# Maximum number of lines in a module
319
+max-module-lines=1000
320
+
321
+# List of optional constructs for which whitespace checking is disabled. `dict-
322
+# separator` is used to allow tabulation in dicts, etc.: {1  : 1,\n222: 2}.
323
+# `trailing-comma` allows a space between comma and closing bracket: (a, ).
324
+# `empty-line` allows space-only lines.
325
+no-space-check=trailing-comma,
326
+               dict-separator
327
+
328
+# Allow the body of a class to be on the same line as the declaration if body
329
+# contains single statement.
330
+single-line-class-stmt=no
331
+
332
+# Allow the body of an if to be on the same line as the test if there is no
333
+# else.
334
+single-line-if-stmt=no
335
+
336
+
337
+[MISCELLANEOUS]
338
+
339
+# List of note tags to take in consideration, separated by a comma.
340
+notes=FIXME,
341
+      XXX,
342
+      TODO
343
+
344
+
345
+[LOGGING]
346
+
347
+# Logging modules to check that the string format arguments are in logging
348
+# function parameter format
349
+logging-modules=logging
350
+
351
+
352
+[SIMILARITIES]
353
+
354
+# Ignore comments when computing similarities.
355
+ignore-comments=yes
356
+
357
+# Ignore docstrings when computing similarities.
358
+ignore-docstrings=yes
359
+
360
+# Ignore imports when computing similarities.
361
+ignore-imports=no
362
+
363
+# Minimum lines number of a similarity.
364
+min-similarity-lines=4
365
+
366
+
367
+[SPELLING]
368
+
369
+# Limits count of emitted suggestions for spelling mistakes
370
+max-spelling-suggestions=4
371
+
372
+# Spelling dictionary name. Available dictionaries: none. To make it working
373
+# install python-enchant package.
374
+spelling-dict=
375
+
376
+# List of comma separated words that should not be checked.
377
+spelling-ignore-words=
378
+
379
+# A path to a file that contains private dictionary; one word per line.
380
+spelling-private-dict-file=
381
+
382
+# Tells whether to store unknown words to indicated private dictionary in
383
+# --spelling-private-dict-file option instead of raising a message.
384
+spelling-store-unknown-words=no
385
+
386
+
387
+[TYPECHECK]
388
+
389
+# List of decorators that produce context managers, such as
390
+# contextlib.contextmanager. Add to this list to register other decorators that
391
+# produce valid context managers.
392
+contextmanager-decorators=contextlib.contextmanager
393
+
394
+# List of members which are set dynamically and missed by pylint inference
395
+# system, and so shouldn't trigger E1101 when accessed. Python regular
396
+# expressions are accepted.
397
+generated-members=
398
+
399
+# Tells whether missing members accessed in mixin class should be ignored. A
400
+# mixin class is detected if its name ends with "mixin" (case insensitive).
401
+ignore-mixin-members=yes
402
+
403
+# This flag controls whether pylint should warn about no-member and similar
404
+# checks whenever an opaque object is returned when inferring. The inference
405
+# can return multiple potential results while evaluating a Python object, but
406
+# some branches might not be evaluated, which results in partial inference. In
407
+# that case, it might be useful to still emit no-member and other checks for
408
+# the rest of the inferred objects.
409
+ignore-on-opaque-inference=yes
410
+
411
+# List of class names for which member attributes should not be checked (useful
412
+# for classes with dynamically set attributes). This supports the use of
413
+# qualified names.
414
+ignored-classes=optparse.Values,thread._local,_thread._local
415
+
416
+# List of module names for which member attributes should not be checked
417
+# (useful for modules/projects where namespaces are manipulated during runtime
418
+# and thus existing member attributes cannot be deduced by static analysis. It
419
+# supports qualified module names, as well as Unix pattern matching.
420
+ignored-modules=
421
+
422
+# Show a hint with possible names when a member name was not found. The aspect
423
+# of finding the hint is based on edit distance.
424
+missing-member-hint=yes
425
+
426
+# The minimum edit distance a name should have in order to be considered a
427
+# similar match for a missing member name.
428
+missing-member-hint-distance=1
429
+
430
+# The total number of similar names that should be taken in consideration when
431
+# showing a hint for a missing member.
432
+missing-member-max-choices=1
433
+
434
+
435
+[VARIABLES]
436
+
437
+# List of additional names supposed to be defined in builtins. Remember that
438
+# you should avoid to define new builtins when possible.
439
+additional-builtins=
440
+
441
+# Tells whether unused global variables should be treated as a violation.
442
+allow-global-unused-variables=yes
443
+
444
+# List of strings which can identify a callback function by name. A callback
445
+# name must start or end with one of those strings.
446
+callbacks=cb_,
447
+          _cb
448
+
449
+# A regular expression matching the name of dummy variables (i.e. expectedly
450
+# not used).
451
+dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_
452
+
453
+# Argument names that match this expression will be ignored. Default to name
454
+# with leading underscore
455
+ignored-argument-names=_.*|^ignored_|^unused_
456
+
457
+# Tells whether we should check for unused import in __init__ files.
458
+init-import=no
459
+
460
+# List of qualified module names which can have objects that can redefine
461
+# builtins.
462
+redefining-builtins-modules=six.moves,past.builtins,future.builtins
463
+
464
+
465
+[IMPORTS]
466
+
467
+# Allow wildcard imports from modules that define __all__.
468
+allow-wildcard-with-all=no
469
+
470
+# Analyse import fallback blocks. This can be used to support both Python 2 and
471
+# 3 compatible code, which means that the block might have code that exists
472
+# only in one or another interpreter, leading to false positives when analysed.
473
+analyse-fallback-blocks=no
474
+
475
+# Deprecated modules which should not be used, separated by a comma
476
+deprecated-modules=regsub,
477
+                   TERMIOS,
478
+                   Bastion,
479
+                   rexec
480
+
481
+# Create a graph of external dependencies in the given file (report RP0402 must
482
+# not be disabled)
483
+ext-import-graph=
484
+
485
+# Create a graph of every (i.e. internal and external) dependencies in the
486
+# given file (report RP0402 must not be disabled)
487
+import-graph=
488
+
489
+# Create a graph of internal dependencies in the given file (report RP0402 must
490
+# not be disabled)
491
+int-import-graph=
492
+
493
+# Force import order to recognize a module as part of the standard
494
+# compatibility libraries.
495
+known-standard-library=
496
+
497
+# Force import order to recognize a module as part of a third party library.
498
+known-third-party=enchant
499
+
500
+
501
+[CLASSES]
502
+
503
+# List of method names used to declare (i.e. assign) instance attributes.
504
+defining-attr-methods=__init__,
505
+                      __new__,
506
+                      setUp
507
+
508
+# List of member names, which should be excluded from the protected access
509
+# warning.
510
+exclude-protected=_asdict,
511
+                  _fields,
512
+                  _replace,
513
+                  _source,
514
+                  _make
515
+
516
+# List of valid names for the first argument in a class method.
517
+valid-classmethod-first-arg=cls
518
+
519
+# List of valid names for the first argument in a metaclass class method.
520
+valid-metaclass-classmethod-first-arg=mcs
521
+
522
+
523
+[DESIGN]
524
+
525
+# Maximum number of arguments for function / method
526
+max-args=5
527
+
528
+# Maximum number of attributes for a class (see R0902).
529
+max-attributes=11
530
+
531
+# Maximum number of boolean expressions in a if statement
532
+max-bool-expr=5
533
+
534
+# Maximum number of branch for function / method body
535
+max-branches=12
536
+
537
+# Maximum number of locals for function / method body
538
+max-locals=15
539
+
540
+# Maximum number of parents for a class (see R0901).
541
+max-parents=7
542
+
543
+# Maximum number of public methods for a class (see R0904).
544
+max-public-methods=25
545
+
546
+# Maximum number of return / yield for function / method body
547
+max-returns=6
548
+
549
+# Maximum number of statements in function / method body
550
+max-statements=50
551
+
552
+# Minimum number of public methods for a class (see R0903).
553
+min-public-methods=2
554
+
555
+
556
+[EXCEPTIONS]
557
+
558
+# Exceptions that will emit a warning when being caught. Defaults to
559
+# "Exception"
560
+overgeneral-exceptions=Exception

+ 1
- 0
.travis.yml View File

@@ -11,4 +11,5 @@ matrix:
11 11
     - python: "3.6"
12 12
 
13 13
 script:
14
+  - pylint bme280
14 15
   - pytest

+ 5
- 5
bme280/__init__.py View File

@@ -1,6 +1,6 @@
1 1
 
2
-from bme280 import Bme280
3
-from bme280 import HO_SKIPPED, HO_1, HO_2, HO_4, HO_8, HO_16, PO_SKIPPED, PO_1, PO_2, PO_4, PO_8, PO_16, TO_SKIPPED, TO_1, TO_2, TO_4, TO_8, TO_16
4
-from bme280 import MODE_SLEEP, MODE_FORCED, MODE_NORMAL
5
-from bme280 import TSTANDBY_0_5, TSTANDBY_62_5, TSTANDBY_125, TSTANDBY_250, TSTANDBY_500, TSTANDBY_1000, TSTANDBY_10, TSTANDBY_20
6
-from bme280 import FILTER_OFF, FILTER_2, FILTER_4, FILTER_8, FILTER_16
2
+from .bme280 import Bme280
3
+from .bme280 import HO_SKIPPED, HO_1, HO_2, HO_4, HO_8, HO_16, PO_SKIPPED, PO_1, PO_2, PO_4, PO_8, PO_16, TO_SKIPPED, TO_1, TO_2, TO_4, TO_8, TO_16
4
+from .bme280 import MODE_SLEEP, MODE_FORCED, MODE_NORMAL
5
+from .bme280 import TSTANDBY_0_5, TSTANDBY_62_5, TSTANDBY_125, TSTANDBY_250, TSTANDBY_500, TSTANDBY_1000, TSTANDBY_10, TSTANDBY_20
6
+from .bme280 import FILTER_OFF, FILTER_2, FILTER_4, FILTER_8, FILTER_16

+ 57
- 54
bme280/bme280.py View File

@@ -1,57 +1,58 @@
1 1
 
2
-import smbus
3 2
 import time
4 3
 
5
-ADDR=0x76 # 7bit address of the BME280 for SDO=0, else 0x77
6
-
7
-REGISTER_ID=0xD0
8
-REGISTER_RESET=0xE0
9
-REGISTER_CTRL_HUM=0xF2
10
-REGISTER_STATUS=0xF3
11
-REGISTER_CTRL_MEAS=0xF4
12
-REGISTER_CONFIG=0xF5
13
-
14
-HO_SKIPPED=0x00
15
-HO_1=0x01
16
-HO_2=0x02
17
-HO_4=0x03
18
-HO_8=0x04
19
-HO_16=0x05 # and all higher
20
-
21
-PO_SKIPPED=0x00
22
-PO_1=0x01
23
-PO_2=0x02
24
-PO_4=0x03
25
-PO_8=0x04
26
-PO_16=0x05 # and all higher
27
-
28
-TO_SKIPPED=0x00
29
-TO_1=0x01
30
-TO_2=0x02
31
-TO_4=0x03
32
-TO_8=0x04
33
-TO_16=0x05 # and all higher
34
-
35
-MODE_SLEEP=0x00
36
-MODE_FORCED=0x01 # and 0x02
37
-MODE_NORMAL=0x03
38
-
39
-TSTANDBY_0_5=0x00
40
-TSTANDBY_62_5=0x01
41
-TSTANDBY_125=0x02
42
-TSTANDBY_250=0x03
43
-TSTANDBY_500=0x04
44
-TSTANDBY_1000=0x05
45
-TSTANDBY_10=0x06
46
-TSTANDBY_20=0x07
47
-
48
-FILTER_OFF=0x00
49
-FILTER_2=0x01
50
-FILTER_4=0x02
51
-FILTER_8=0x03
52
-FILTER_16=0x04 # and all higher
53
-
54
-class Bme280:
4
+import smbus # pylint: disable=import-error
5
+
6
+ADDR = 0x76 # 7bit address of the BME280 for SDO=0, else 0x77
7
+
8
+REGISTER_ID = 0xD0
9
+REGISTER_RESET = 0xE0
10
+REGISTER_CTRL_HUM = 0xF2
11
+REGISTER_STATUS = 0xF3
12
+REGISTER_CTRL_MEAS = 0xF4
13
+REGISTER_CONFIG = 0xF5
14
+
15
+HO_SKIPPED = 0x00
16
+HO_1 = 0x01
17
+HO_2 = 0x02
18
+HO_4 = 0x03
19
+HO_8 = 0x04
20
+HO_16 = 0x05 # and all higher
21
+
22
+PO_SKIPPED = 0x00
23
+PO_1 = 0x01
24
+PO_2 = 0x02
25
+PO_4 = 0x03
26
+PO_8 = 0x04
27
+PO_16 = 0x05 # and all higher
28
+
29
+TO_SKIPPED = 0x00
30
+TO_1 = 0x01
31
+TO_2 = 0x02
32
+TO_4 = 0x03
33
+TO_8 = 0x04
34
+TO_16 = 0x05 # and all higher
35
+
36
+MODE_SLEEP = 0x00
37
+MODE_FORCED = 0x01 # and 0x02
38
+MODE_NORMAL = 0x03
39
+
40
+TSTANDBY_0_5 = 0x00
41
+TSTANDBY_62_5 = 0x01
42
+TSTANDBY_125 = 0x02
43
+TSTANDBY_250 = 0x03
44
+TSTANDBY_500 = 0x04
45
+TSTANDBY_1000 = 0x05
46
+TSTANDBY_10 = 0x06
47
+TSTANDBY_20 = 0x07
48
+
49
+FILTER_OFF = 0x00
50
+FILTER_2 = 0x01
51
+FILTER_4 = 0x02
52
+FILTER_8 = 0x03
53
+FILTER_16 = 0x04 # and all higher
54
+
55
+class Bme280(object):
55 56
 
56 57
     def __init__(self, i2c_bus=1, sensor_address=ADDR):
57 58
         self.bus = smbus.SMBus(i2c_bus)
@@ -137,7 +138,7 @@ class Bme280:
137 138
 
138 139
         pressure_raw = (data[0] << 12) | (data[1] << 4) | (data[2] >> 4)
139 140
         temperature_raw = (data[3] << 12) | (data[4] << 4) | (data[5] >> 4)
140
-        humidity_raw  = (data[6] << 8)  |  data[7]
141
+        humidity_raw = (data[6] << 8) | data[7]
141 142
         t_fine = self.calc_t_fine(temperature_raw)
142 143
         t = self.calc_compensated_temperature(t_fine)
143 144
         p = self.calc_compensated_pressure(t_fine, pressure_raw)
@@ -153,7 +154,7 @@ class Bme280:
153 154
         """
154 155
         returns the bit pattern for CTRL_HUM corresponding to the desired state of this class
155 156
         """
156
-        return (self.ho & 0x07)
157
+        return self.ho & 0x07
157 158
 
158 159
     def get_reg_ctrl_meas(self):
159 160
         """
@@ -179,6 +180,8 @@ class Bme280:
179 180
         for i in range(0xE1, 0xE1+7):
180 181
             calibration_regs.append(self.bus.read_byte_data(self.sensor_address, i))
181 182
 
183
+        # pylint: disable=bad-whitespace
184
+
182 185
         # reorganize 8-bit words into compensation words (without correct sign)
183 186
         self.digT = []
184 187
         self.digT.append((calibration_regs[1] << 8) | calibration_regs[0])
@@ -256,4 +259,4 @@ class Bme280:
256 259
             var_H = 100.0
257 260
         elif var_H < 0.0:
258 261
             var_H = 0.0
259
-        return var_H
262
+        return var_H

+ 8
- 6
demo.py View File

@@ -1,10 +1,12 @@
1
+#!/usr/bin/env python
2
+# -*- coding: UTF-8 -*-
1 3
 
2 4
 import bme280
3 5
 
4 6
 if __name__ == '__main__':
5
-  bme = bme280.Bme280()
6
-  bme.set_mode(bme280.MODE_FORCED)
7
-  t, p, h = bme.get_data()
8
-  print "Temperature: %f °C" % t
9
-  print "Pressure: %f P" % p
10
-  print "Humidity: %f %" % h
7
+    bme = bme280.Bme280()
8
+    bme.set_mode(bme280.MODE_FORCED)
9
+    t, p, h = bme.get_data()
10
+    print "Temperature: %f °C" % t
11
+    print "Pressure: %f P" % p
12
+    print "Humidity: %f %%" % h

+ 1
- 0
requirements.txt View File

@@ -1,3 +1,4 @@
1 1
 mock==2.0.0
2
+pylint==1.8.2
2 3
 pytest==3.0.6
3 4
 snapshottest==0.5.0