Skip to content

Commit 0df3307

Browse files
committed
Even more Linting
1 parent 2f5bd15 commit 0df3307

2 files changed

Lines changed: 18 additions & 13 deletions

File tree

PyPortal_Calculator/calculator.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
"""
2-
Class that handles the input_key and calculations
2+
CircuitPython library to handle the input and calculations
3+
4+
* Author(s): Melissa LeBlanc-Williams
35
"""
6+
7+
# pylint: disable=eval-used
48
class Calculator:
59
def __init__(self, calc_display, clear_button, label_offset):
610
self._calc_display = calc_display
@@ -10,21 +14,22 @@ def __init__(self, calc_display, clear_button, label_offset):
1014
self._operator = None
1115
self._equal_pressed = False
1216
self._operand = None
13-
self.all_clear()
17+
self._all_clear()
1418

1519
def calculate(self, number_one, operator, number_two):
20+
1621
result = eval(number_one + operator + number_two)
1722
if int(result) == result:
1823
result = int(result)
1924
return str(result)
2025

21-
def all_clear(self):
26+
def _all_clear(self):
2227
self._accumulator = "0"
2328
self._operator = None
2429
self._equal_pressed = False
25-
self.clear_entry()
30+
self._clear_entry()
2631

27-
def clear_entry(self):
32+
def _clear_entry(self):
2833
self._operand = None
2934
self._set_button_ce(False)
3035
self._set_text("0")
@@ -78,7 +83,7 @@ def _handle_operator(self, input_key):
7883
self._accumulator = self._get_text()
7984
self._equal_pressed = False
8085

81-
def _handle_equal(self, input_key):
86+
def _handle_equal(self):
8287
if self._operator is not None:
8388
if self._operand is None:
8489
self._operand = self._get_text()
@@ -89,9 +94,9 @@ def _handle_equal(self, input_key):
8994
def add_input(self, input_key):
9095
try:
9196
if input_key == "AC":
92-
self.all_clear()
97+
self._all_clear()
9398
elif input_key == "CE":
94-
self.clear_entry()
99+
self._clear_entry()
95100
elif self._operator is None and input_key == "0":
96101
pass
97102
elif len(input_key) == 1 and 48 <= ord(input_key) <= 57:
@@ -108,7 +113,7 @@ def add_input(self, input_key):
108113
elif input_key == "%":
109114
self._set_text(self.calculate(self._get_text(), "/", "100"))
110115
elif input_key == "=":
111-
self._handle_equal(input_key)
116+
self._handle_equal()
112117
except (ZeroDivisionError, RuntimeError):
113-
self.all_clear()
118+
self._all_clear()
114119
self._set_text("Error")

PyPortal_Calculator/code.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ def button_grid(row, col):
5454
def make_button(row, col, label, width=1, color=WHITE, text_color=BLACK):
5555
pos = button_grid(row, col)
5656
new_button = Button(x=pos.x, y=pos.y,
57-
width=BUTTON_WIDTH * width + BUTTON_MARGIN * (width - 1), height=BUTTON_HEIGHT,
58-
label=label, label_font=font, label_color=text_color, fill_color=color,
59-
style=Button.ROUNDRECT)
57+
width=BUTTON_WIDTH * width + BUTTON_MARGIN * (width - 1),
58+
height=BUTTON_HEIGHT, label=label, label_font=font,
59+
label_color=text_color, fill_color=color, style=Button.ROUNDRECT)
6060
buttons.append(new_button)
6161
return new_button
6262

0 commit comments

Comments
 (0)