Skip to content

Commit 577fcb5

Browse files
committed
fix: Typing / Linting Errors
The code base was ported from python2 on a whim, and a lot of the code reflects that. This tidies up the typing and linting a little more
1 parent 039ab4b commit 577fcb5

File tree

4 files changed

+34
-27
lines changed

4 files changed

+34
-27
lines changed

filament_scale_enhanced/__init__.py

+21-22
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
# coding=utf-8
22
from __future__ import absolute_import
33

4-
import flask
54
import octoprint.plugin
65

76
from .fse_version import VERSION as __version__ # noqa: F401
87
from .hx711 import HX711
98

109
try:
11-
import RPi.GPIO as GPIO
10+
from RPi import GPIO
1211
except (ModuleNotFoundError, RuntimeError):
13-
import Mock.GPIO as GPIO # noqa: F401
12+
from Mock import GPIO # noqa: F401
1413

1514

1615
# pylint: disable=too-many-ancestors
@@ -26,27 +25,27 @@ class FilamentScalePlugin(
2625
tq = None
2726

2827
@staticmethod
29-
def get_template_configs():
30-
return [dict(type="settings", custom_bindings=True)]
28+
def get_template_configs(): # pylint: disable=arguments-differ
29+
return [{"type": "settings", "custom_bindings": True}]
3130

3231
@staticmethod
33-
def get_settings_defaults():
34-
return dict(
35-
tare=8430152,
36-
reference_unit=-411,
37-
spool_weight=200,
38-
clockpin=21,
39-
datapin=20,
40-
lastknownweight=0,
41-
)
32+
def get_settings_defaults(): # pylint: disable=arguments-differ
33+
return {
34+
"tare": 8430152,
35+
"reference_unit": -411,
36+
"spool_weight": 200,
37+
"clockpin": 21,
38+
"datapin": 20,
39+
"lastknownweight": 0,
40+
}
4241

4342
@staticmethod
44-
def get_assets():
45-
return dict(
46-
js=["js/filament_scale.js"],
47-
css=["css/filament_scale.css"],
48-
less=["less/filament_scale.less"],
49-
)
43+
def get_assets(): # pylint: disable=arguments-differ
44+
return {
45+
"js": ["js/filament_scale.js"],
46+
"css": ["css/filament_scale.css"],
47+
"less": ["less/filament_scale.less"],
48+
}
5049

5150
def __init__(self):
5251
super().__init__()
@@ -113,10 +112,10 @@ def check_weight(self):
113112
self.last_weight = v
114113
self._plugin_manager.send_plugin_message(self._identifier, v)
115114
self.hx.power_down()
116-
except Exception as err:
115+
except Exception as err: # pylint: disable=broad-exception-caught
117116
self._logger.exception(err)
118117

119-
# pylint: disable=line-too-long
118+
# pylint: disable=line-too-long,use-dict-literal
120119
def get_update_information(self):
121120
# Define the configuration for your plugin to use with the
122121
# Software Update Plugin here.

filament_scale_enhanced/hx711.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
import statistics
33

44
try:
5-
import RPi.GPIO as GPIO
5+
from RPi import GPIO
66
except (ModuleNotFoundError, RuntimeError):
7-
import Mock.GPIO as GPIO
7+
from Mock import GPIO
88

99

1010
def bitsToBytes(a):

pytest.ini

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
[pytest]
22
python_files = tests/__init__.py
33
addopts = -p no:cacheprovider --mypy --pylint --flake8
4+
filterwarnings =
5+
ignore
6+
default:::filament_scale.*
7+
default:::tests.*

setup.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from setuptools import setup
55

66
version = {}
7-
with open("filament_scale_enhanced/fse_version.py") as fp:
7+
with open("filament_scale_enhanced/fse_version.py", encoding="utf8") as fp:
88
exec(fp.read(), version) # pylint: disable=exec-used
99

1010
try:
@@ -38,7 +38,9 @@
3838
'pytest-pylint',
3939
'pylint',
4040
'pytest-flake8',
41-
'Mock.GPIO'
41+
'Mock.GPIO',
42+
# Flake8 is likely a dead end
43+
'flake8<5',
4244
],
4345
'test': [
4446
'pytest',
@@ -47,7 +49,9 @@
4749
'pytest-pylint',
4850
'pylint',
4951
'pytest-flake8',
50-
'Mock.GPIO'
52+
'Mock.GPIO',
53+
# Flake8 is likely a dead end
54+
'flake8<5',
5155
]
5256
}
5357

0 commit comments

Comments
 (0)