Skip to content

Commit 0314486

Browse files
committed
Edit to use chained context manager statements
1 parent 6028516 commit 0314486

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

adafruit_macropad.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -887,17 +887,15 @@ def play_file(self, file_name):
887887
if file_name.lower().endswith(".wav"):
888888
with audiopwmio.PWMAudioOut(
889889
board.SPEAKER
890-
) as audio: # pylint: disable=not-callable
891-
with open(file_name, "rb") as audio_file:
890+
) as audio, open(file_name, "rb") as audio_file: # pylint: disable=not-callable
892891
wavefile = audiocore.WaveFile(audio_file)
893892
audio.play(wavefile)
894893
while audio.playing:
895894
pass
896895
elif file_name.lower().endswith(".mp3"):
897896
with audiopwmio.PWMAudioOut(
898897
board.SPEAKER
899-
) as audio: # pylint: disable=not-callable
900-
with open(file_name, "rb") as audio_file:
898+
) as audio, open(file_name, "rb") as audio_file: # pylint: disable=not-callable
901899
mp3file = audiomp3.MP3Decoder(audio_file)
902900
audio.play(mp3file)
903901
while audio.playing:

0 commit comments

Comments
 (0)