Skip to content

Commit 9a88789

Browse files
committed
fix a buch of flake8 errors
1 parent ec51264 commit 9a88789

13 files changed

Lines changed: 27 additions & 34 deletions

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,4 +180,4 @@
180180
epub_exclude_files = ['search.html']
181181

182182

183-
# -- Extension configuration -------------------------------------------------
183+
# -- Extension configuration -------------------------------------------------

examples/dispatcher.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from pythonosc.dispatcher import Dispatcher
22
from typing import List, Any
3+
from pythonosc.osc_server import BlockingOSCUDPServer
4+
from pythonosc.udp_client import SimpleUDPClient
35

46
dispatcher = Dispatcher()
57

@@ -22,8 +24,6 @@ def set_filter(address: str, *args: List[Any]) -> None:
2224
dispatcher.map("/filter*", set_filter) # Map wildcard address to set_filter function
2325

2426
# Set up server and client for testing
25-
from pythonosc.osc_server import BlockingOSCUDPServer
26-
from pythonosc.udp_client import SimpleUDPClient
2727

2828
server = BlockingOSCUDPServer(("127.0.0.1", 1337), dispatcher)
2929
client = SimpleUDPClient("127.0.0.1", 1337)

examples/simple_2way.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
"""Small example OSC server anbd client combined
2-
This program listens to serveral addresses and print if there is an input.
2+
This program listens to serveral addresses and print if there is an input.
33
It also transmits on a different port at the same time random values to different addresses.
44
This can be used to demonstrate concurrent send and recieve over OSC
55
"""
66

77
import argparse
88
import random
99
import time
10-
import math
1110
import threading
1211

1312
from pythonosc import udp_client
@@ -22,6 +21,7 @@ def print_fader_handler(unused_addr, args, value):
2221
def print_xy_fader_handler(unused_addr, args, value1, value2):
2322
print("[{0}] ~ {1:0.2f} ~ {2:0.2f}".format(args[0], value2, value1))
2423

24+
2525
if __name__ == "__main__":
2626
parser = argparse.ArgumentParser()
2727
parser.add_argument("--serverip", default="127.0.0.1", help="The ip to listen on")
@@ -30,24 +30,24 @@ def print_xy_fader_handler(unused_addr, args, value1, value2):
3030
parser.add_argument("--clientport", type=int, default=5006, help="The port the OSC Client is listening on")
3131
args = parser.parse_args()
3232

33-
34-
# listen to addresses and print changes in values
33+
# listen to addresses and print changes in values
3534
dispatcher = Dispatcher()
3635
dispatcher.map("/1/push2", print)
3736
dispatcher.map("/1/fader1", print_fader_handler, "Focus")
3837
dispatcher.map("/1/fader2", print_fader_handler, "Zoom")
3938
dispatcher.map("/1/xy1", print_xy_fader_handler, "Pan-Tilt")
4039
dispatcher.map("/ping", print)
4140

42-
def start_server(ip, port):
4341

42+
def start_server(ip, port):
4443
print("Starting Server")
4544
server = osc_server.ThreadingOSCUDPServer(
4645
(ip, port), dispatcher)
4746
print("Serving on {}".format(server.server_address))
4847
thread = threading.Thread(target=server.serve_forever)
4948
thread.start()
5049

50+
5151
def start_client(ip, port):
5252
print("Starting Client")
5353
client = udp_client.SimpleUDPClient(ip, port)
@@ -57,16 +57,13 @@ def start_client(ip, port):
5757

5858

5959
# send random values between 0-1 to the three addresses
60-
def random_values(client):
60+
def random_values(client):
6161
while True:
6262
for x in range(10):
6363
client.send_message("/1/fader2", random.random())
6464
client.send_message("/1/fader1", random.random())
6565
client.send_message("/1/xy1", [random.random(), random.random()])
6666
time.sleep(.5)
6767

68-
6968
start_server(args.serverip, args.serverport)
7069
start_client(args.clientip, args.clientport)
71-
72-

examples/simple_client.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import random
88
import time
99

10-
from pythonosc import osc_message_builder
1110
from pythonosc import udp_client
1211

1312
if __name__ == "__main__":

pythonosc/osc_message_builder.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77

88
ArgValue = Union[str, bytes, bool, int, float, osc_types.MidiPacket, list]
99

10+
1011
class BuildError(Exception):
1112
"""Error raised when an incomplete message is trying to be built."""
1213

14+
1315
class OscMessageBuilder(object):
1416
"""Builds arbitrary OscMessage instances."""
1517

@@ -79,7 +81,7 @@ def add_arg(self, arg_value: ArgValue, arg_type: Optional[str] = None) -> None:
7981
if arg_type and not self._valid_type(arg_type):
8082
raise ValueError(
8183
'arg_type must be one of {}, or an array of valid types'
82-
.format(self._SUPPORTED_ARG_TYPES))
84+
.format(self._SUPPORTED_ARG_TYPES))
8385
if not arg_type:
8486
arg_type = self._get_arg_type(arg_value)
8587
if isinstance(arg_type, list):

pythonosc/osc_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def __init__(self, server_address: Tuple[str, int], dispatcher: Dispatcher, bind
5555
Args:
5656
server_address: IP and port of server
5757
dispatcher: Dispatcher this server will use
58-
(optional) bind_and_activate: default=True defines if the server has to start on call of constructor
58+
(optional) bind_and_activate: default=True defines if the server has to start on call of constructor
5959
"""
6060
super().__init__(server_address, _UDPHandler, bind_and_activate)
6161
self._dispatcher = dispatcher

pythonosc/parsing/ntp.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,18 @@
2828

2929

3030
class NtpError(Exception):
31-
"""Base class for ntp module errors."""
31+
"""Base class for ntp module errors."""
3232

3333

3434
def parse_timestamp(timestamp: int) -> Timestamp:
35-
"""Parse NTP timestamp as Timetag.
36-
"""
35+
"""Parse NTP timestamp as Timetag."""
3736
seconds = timestamp >> 32
3837
fraction = timestamp & 0xFFFFFFFF
3938
return Timestamp(seconds, fraction)
4039

4140

4241
def ntp_to_system_time(timestamp: bytes) -> float:
43-
"""Convert a NTP timestamp to system time in seconds.
44-
"""
42+
"""Convert a NTP timestamp to system time in seconds."""
4543
try:
4644
timestamp = struct.unpack('>Q', timestamp)[0]
4745
except Exception as e:
@@ -50,22 +48,19 @@ def ntp_to_system_time(timestamp: bytes) -> float:
5048

5149

5250
def system_time_to_ntp(seconds: float) -> bytes:
53-
"""Convert a system time in seconds to NTP timestamp.
54-
"""
51+
"""Convert a system time in seconds to NTP timestamp."""
5552
try:
56-
seconds = seconds + _NTP_DELTA
53+
seconds = seconds + _NTP_DELTA
5754
except TypeError as e:
58-
raise NtpError(e)
55+
raise NtpError(e)
5956
return struct.pack('>Q', int(seconds * _SECONDS_TO_NTP_TIMESTAMP))
6057

6158

6259
def ntp_time_to_system_epoch(seconds: float) -> float:
63-
"""Convert a NTP time in seconds to system time in seconds.
64-
"""
60+
"""Convert a NTP time in seconds to system time in seconds."""
6561
return seconds - _NTP_DELTA
6662

6763

6864
def system_time_to_ntp_epoch(seconds: float) -> float:
69-
"""Convert a system time in seconds to NTP time in seconds.
70-
"""
65+
"""Convert a system time in seconds to NTP time in seconds."""
7166
return seconds + _NTP_DELTA

pythonosc/parsing/osc_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import struct
44

55
from pythonosc.parsing import ntp
6-
from datetime import datetime, timedelta, date
6+
from datetime import datetime, timedelta
77

88
from typing import Union, Tuple, cast
99

pythonosc/test/parsing/test_osc_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ class TestMidi(unittest.TestCase):
125125
def test_get_midi(self):
126126
cases = {
127127
b"\x00\x00\x00\x00": ((0, 0, 0, 0), 4),
128-
b"\x00\x00\x00\x02": ((0, 0, 0, 1), 4),
128+
b"\x00\x00\x00\x01": ((0, 0, 0, 1), 4),
129129
b"\x00\x00\x00\x02": ((0, 0, 0, 2), 4),
130130
b"\x00\x00\x00\x03": ((0, 0, 0, 3), 4),
131131

pythonosc/test/test_dispatcher.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,11 @@ def test_unmap_exception(self):
142142
def dummyhandler():
143143
pass
144144

145-
with self.assertRaises(ValueError) as context:
145+
with self.assertRaises(ValueError):
146146
self.dispatcher.unmap("/unmap/exception", dummyhandler)
147147

148148
handlerobj = self.dispatcher.map("/unmap/somethingelse", dummyhandler())
149-
with self.assertRaises(ValueError) as context:
149+
with self.assertRaises(ValueError):
150150
self.dispatcher.unmap("/unmap/exception", handlerobj)
151151

152152

0 commit comments

Comments
 (0)