Skip to content

Commit bedb4de

Browse files
committed
Code style changes to please Pylint
1 parent a4d521a commit bedb4de

File tree

8 files changed

+44
-28
lines changed

8 files changed

+44
-28
lines changed

.github/workflows/pylint.yml

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,20 @@ jobs:
77
runs-on: ubuntu-latest
88
strategy:
99
matrix:
10-
python-version: ["3.8", "3.9", "3.10"]
10+
python-version: ["3.10", "3.11"]
1111
steps:
12-
- uses: actions/checkout@v4
13-
- name: Set up Python ${{ matrix.python-version }}
14-
uses: actions/setup-python@v3
15-
with:
16-
python-version: ${{ matrix.python-version }}
17-
- name: Install dependencies
18-
run: |
19-
python -m pip install --upgrade pip
20-
pip install pylint
21-
- name: Analysing the code with pylint
22-
run: |
23-
pylint $(git ls-files '*.py')
12+
- uses: actions/checkout@v4
13+
- name: Set up Python ${{ matrix.python-version }}
14+
uses: actions/setup-python@v3
15+
with:
16+
python-version: ${{ matrix.python-version }}
17+
- name: Install dependencies
18+
run: |
19+
python -m pip install --upgrade pip
20+
pip install -r requirements.txt
21+
pip install pylint
22+
- name: Copy example words file
23+
run: cp words.example.py words.py
24+
- name: Analysing the code with pylint
25+
run: |
26+
pylint $(git ls-files '*.py') --indent-string=' ' --disable=missing-module-docstring

cli_light.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33

44
class CLILight(Light):
5+
"""
6+
Simulates a light on the command line
7+
"""
8+
59
block = ' ' * 42
610

711
def on(self):

flash.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
#!/usr/bin/env python
22

3+
import time
4+
35
from cli_light import CLILight
46
from morsecode import MorseCodeFlasher
5-
import time
67
from word_of_the_day import send_todays_word
78

89

910
# The length of a beat in seconds
10-
a_beat = .15
11+
A_BEAT = .15
1112

12-
delay_between_letters = 8 * a_beat
13+
DELAY_BETWEEN_LETTERS = 8 * A_BEAT
1314

1415
light = CLILight()
15-
code_flasher = MorseCodeFlasher(a_beat, delay_between_letters, light)
16+
code_flasher = MorseCodeFlasher(A_BEAT, DELAY_BETWEEN_LETTERS, light)
1617

17-
time.sleep(2 * a_beat)
18+
time.sleep(2 * A_BEAT)
1819

1920
send_todays_word(code_flasher)

light.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ def off(self):
77
print("Off")
88

99
def finish(self):
10-
return
10+
return

listen.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,15 @@
2424
wiringpi.pinMode(PIN_BUTTON, wiringpi.GPIO.INPUT)
2525

2626
# The length of a beat in seconds
27-
a_beat = .15
27+
A_BEAT = .15
2828

29-
delay_between_letters = 8 * a_beat
29+
DELAY_BETWEEN_LETTERS = 8 * A_BEAT
3030

3131

3232
class PiBorgLight(Light):
33+
"""
34+
Controls the illumination of PiBorg LED
35+
"""
3336

3437
# Set the colour channel intensity (1 is fully on, 0 is off)
3538
red = 1
@@ -51,13 +54,13 @@ def off(self):
5154

5255

5356
light = PiBorgLight()
54-
code_flasher = MorseCodeFlasher(a_beat, delay_between_letters, light)
57+
code_flasher = MorseCodeFlasher(A_BEAT, DELAY_BETWEEN_LETTERS, light)
5558

5659

5760
def record_push():
58-
url = 'http://morse.pelmo.uk/ping/index.php'
61+
url = 'http://morse.pelmo.uk/ping/index.php'
5962
headers = {
60-
'Content-Type': 'multipart/form-data',
63+
'Content-Type': 'multipart/form-data',
6164
'User-Agent': 'Morse code RaspberryPi'
6265
}
6366
try:
@@ -66,7 +69,7 @@ def record_push():
6669
data={ 'ping': 1 },
6770
timeout=3
6871
)
69-
print('Response code: ' + str(response.status_code))
72+
print('Response code: ' + str(response.status_code))
7073
except:
7174
print('Post failed')
7275

@@ -78,6 +81,6 @@ def record_push():
7881
while True: # Run forever
7982
if wiringpi.digitalRead(PIN_BUTTON):
8083
print("Button was pushed!")
81-
time.sleep(2 * a_beat)
84+
time.sleep(2 * A_BEAT)
8285
send_todays_word(code_flasher)
8386
# record_push()

morsecode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def __light_up_for(self, seconds: float):
5050

5151
def __dash(self):
5252
self.__light_up_for(6 * self.a_beat)
53-
53+
5454

5555
def __dot(self):
5656
self.__light_up_for(self.a_beat)

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
requests
2+
wiringpi

word_of_the_day.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
from datetime import date
22

3-
from light import Light
43
from morsecode import MorseCodeFlasher
54
from words import words
65

76

87
def send_todays_word(code_flasher: MorseCodeFlasher):
8+
"""
9+
Establishes what today's word of the day is and sends to code_flasher
10+
"""
11+
912
today = date.today()
1013
month = today.strftime("%b")
1114
day = int(today.strftime("%d"))

0 commit comments

Comments
 (0)