Skip to content

Commit 2a63fe2

Browse files
committed
Fix some error reported by Pyright
1 parent d12f60f commit 2a63fe2

File tree

11 files changed

+21
-22
lines changed

11 files changed

+21
-22
lines changed

examples/play_file.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,6 @@ def callback(outdata, frames, time, status):
8080
with stream:
8181
event.wait() # Wait until playback is finished
8282
except KeyboardInterrupt:
83-
parser.exit('\nInterrupted by user')
83+
parser.exit(1, '\nInterrupted by user')
8484
except Exception as e:
85-
parser.exit(type(e).__name__ + ': ' + str(e))
85+
parser.exit(1, type(e).__name__ + ': ' + str(e))

examples/play_long_file.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ def callback(outdata, frames, time, status):
101101
q.put(data, timeout=timeout)
102102
event.wait() # Wait until playback is finished
103103
except KeyboardInterrupt:
104-
parser.exit('\nInterrupted by user')
104+
parser.exit(1, '\nInterrupted by user')
105105
except queue.Full:
106106
# A timeout occurred, i.e. there was an error in the callback
107107
parser.exit(1)
108108
except Exception as e:
109-
parser.exit(type(e).__name__ + ': ' + str(e))
109+
parser.exit(1, type(e).__name__ + ': ' + str(e))

examples/play_long_file_raw.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ def callback(outdata, frames, time, status):
9292
q.put(data, timeout=timeout)
9393
event.wait() # Wait until playback is finished
9494
except KeyboardInterrupt:
95-
parser.exit('\nInterrupted by user')
95+
parser.exit(1, '\nInterrupted by user')
9696
except queue.Full:
9797
# A timeout occurred, i.e. there was an error in the callback
9898
parser.exit(1)
9999
except Exception as e:
100-
parser.exit(type(e).__name__ + ': ' + str(e))
100+
parser.exit(1, type(e).__name__ + ': ' + str(e))

examples/play_sine.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,6 @@ def callback(outdata, frames, time, status):
5959
print('#' * 80)
6060
input()
6161
except KeyboardInterrupt:
62-
parser.exit('')
62+
parser.exit(1, '\nInterrupted by user')
6363
except Exception as e:
64-
parser.exit(type(e).__name__ + ': ' + str(e))
64+
parser.exit(1, type(e).__name__ + ': ' + str(e))

examples/play_stream.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,16 @@ def int_or_str(text):
6161
info = ffmpeg.probe(args.url)
6262
except ffmpeg.Error as e:
6363
sys.stderr.buffer.write(e.stderr)
64-
parser.exit(e)
64+
parser.exit(1, str(e))
6565

6666
streams = info.get('streams', [])
6767
if len(streams) != 1:
68-
parser.exit('There must be exactly one stream available')
68+
parser.exit(1, 'There must be exactly one stream available')
6969

7070
stream = streams[0]
7171

7272
if stream.get('codec_type') != 'audio':
73-
parser.exit('The stream must be an audio stream')
73+
parser.exit(1, 'The stream must be an audio stream')
7474

7575
channels = stream['channels']
7676
samplerate = float(stream['sample_rate'])
@@ -117,9 +117,9 @@ def callback(outdata, frames, time, status):
117117
while True:
118118
q.put(process.stdout.read(read_size), timeout=timeout)
119119
except KeyboardInterrupt:
120-
parser.exit('\nInterrupted by user')
120+
parser.exit(1, '\nInterrupted by user')
121121
except queue.Full:
122122
# A timeout occurred, i.e. there was an error in the callback
123123
parser.exit(1)
124124
except Exception as e:
125-
parser.exit(type(e).__name__ + ': ' + str(e))
125+
parser.exit(1, type(e).__name__ + ': ' + str(e))

examples/plot_input.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,4 @@ def update_plot(frame):
116116
with stream:
117117
plt.show()
118118
except Exception as e:
119-
parser.exit(type(e).__name__ + ': ' + str(e))
119+
parser.exit(1, type(e).__name__ + ': ' + str(e))

examples/rec_gui.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"""
1313
import contextlib
1414
import queue
15-
import sys
1615
import tempfile
1716
import threading
1817
import tkinter as tk

examples/rec_unlimited.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,4 @@ def callback(indata, frames, time, status):
8383
print('\nRecording finished: ' + repr(args.filename))
8484
parser.exit(0)
8585
except Exception as e:
86-
parser.exit(type(e).__name__ + ': ' + str(e))
86+
parser.exit(1, type(e).__name__ + ': ' + str(e))

examples/spectrogram.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,6 @@ def callback(indata, frames, time, status):
106106
'\x1b[0m', sep='')
107107
break
108108
except KeyboardInterrupt:
109-
parser.exit('Interrupted by user')
109+
parser.exit(1, '\nInterrupted by user')
110110
except Exception as e:
111-
parser.exit(type(e).__name__ + ': ' + str(e))
111+
parser.exit(1, type(e).__name__ + ': ' + str(e))

examples/wire.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,6 @@ def callback(indata, outdata, frames, time, status):
6363
print('#' * 80)
6464
input()
6565
except KeyboardInterrupt:
66-
parser.exit('')
66+
parser.exit(1, '\nInterrupted by user')
6767
except Exception as e:
68-
parser.exit(type(e).__name__ + ': ' + str(e))
68+
parser.exit(1, type(e).__name__ + ': ' + str(e))

0 commit comments

Comments
 (0)