Skip to content

Commit 30ef81c

Browse files
committed
format with black and add gh action to check black format was applied
1 parent e7a4361 commit 30ef81c

30 files changed

Lines changed: 635 additions & 451 deletions

.github/workflows/black.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Lint with Black
2+
3+
on: [push, pull_request]
4+
5+
permissions: read-all
6+
7+
jobs:
8+
lint:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v3
12+
- uses: psf/black@stable

.github/workflows/python-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
# stop the build if there are Python syntax errors or undefined names
3636
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
3737
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
38-
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
38+
flake8 . --count --exit-zero --max-complexity=10 --statistics
3939
- name: Check with mypy
4040
run: mypy pythonosc examples
4141
- name: Test with pytest

CONTRIBUTING.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,9 @@ Thanks for contributing to this package!
22

33
Before sending a PR, please make sure you checked the [python test workflow](.github/workflows/python-test.yml) and ran it locally, either using [act](https://nektosact.com) or by executing the workflow actions yourself.
44

5-
Please only send the PR once all tests pass and mypy is happy, thanks!
5+
TL;DR:
6+
- Format all code with Black
7+
- Provide type annotations with mypy
8+
- Write and run tests with pytest
9+
10+
Please only send the PR once all of the above is done, thanks!

docs/conf.py

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,19 @@
1717
# sys.path.insert(0, os.path.abspath('.'))
1818
import os
1919
import sys
20+
2021
sys.path.insert(0, os.path.abspath(".."))
2122

2223
# -- Project information -----------------------------------------------------
2324

24-
project = 'python-osc'
25-
copyright = '2019, attwad'
26-
author = 'attwad'
25+
project = "python-osc"
26+
copyright = "2019, attwad"
27+
author = "attwad"
2728

2829
# The short X.Y version
29-
version = ''
30+
version = ""
3031
# The full version, including alpha/beta/rc tags
31-
release = '1.7.1'
32+
release = "1.7.1"
3233

3334

3435
# -- General configuration ---------------------------------------------------
@@ -41,24 +42,24 @@
4142
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
4243
# ones.
4344
extensions = [
44-
'sphinx.ext.autodoc',
45-
'sphinx.ext.doctest',
46-
'sphinx.ext.coverage',
47-
'sphinx.ext.viewcode',
48-
'sphinx.ext.napoleon'
45+
"sphinx.ext.autodoc",
46+
"sphinx.ext.doctest",
47+
"sphinx.ext.coverage",
48+
"sphinx.ext.viewcode",
49+
"sphinx.ext.napoleon",
4950
]
5051

5152
# Add any paths that contain templates here, relative to this directory.
52-
templates_path = ['_templates']
53+
templates_path = ["_templates"]
5354

5455
# The suffix(es) of source filenames.
5556
# You can specify multiple suffix as a list of string:
5657
#
5758
# source_suffix = ['.rst', '.md']
58-
source_suffix = '.rst'
59+
source_suffix = ".rst"
5960

6061
# The master toctree document.
61-
master_doc = 'index'
62+
master_doc = "index"
6263

6364
# The language for content autogenerated by Sphinx. Refer to documentation
6465
# for a list of supported languages.
@@ -70,7 +71,7 @@
7071
# List of patterns, relative to source directory, that match files and
7172
# directories to ignore when looking for source files.
7273
# This pattern also affects html_static_path and html_extra_path.
73-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
74+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
7475

7576
# The name of the Pygments (syntax highlighting) style to use.
7677
pygments_style = None
@@ -81,7 +82,7 @@
8182
# The theme to use for HTML and HTML Help pages. See the documentation for
8283
# a list of builtin themes.
8384
#
84-
html_theme = 'sphinx_rtd_theme'
85+
html_theme = "sphinx_rtd_theme"
8586

8687
# Theme options are theme-specific and customize the look and feel of a theme
8788
# further. For a list of options available for each theme, see the
@@ -92,7 +93,7 @@
9293
# Add any paths that contain custom static files (such as style sheets) here,
9394
# relative to this directory. They are copied after the builtin static files,
9495
# so a file named "default.css" will overwrite the builtin "default.css".
95-
html_static_path = ['_static']
96+
html_static_path = ["_static"]
9697

9798
# Custom sidebar templates, must be a dictionary that maps document names
9899
# to template names.
@@ -108,7 +109,7 @@
108109
# -- Options for HTMLHelp output ---------------------------------------------
109110

110111
# Output file base name for HTML help builder.
111-
htmlhelp_basename = 'python-oscdoc'
112+
htmlhelp_basename = "python-oscdoc"
112113

113114

114115
# -- Options for LaTeX output ------------------------------------------------
@@ -117,15 +118,12 @@
117118
# The paper size ('letterpaper' or 'a4paper').
118119
#
119120
# 'papersize': 'letterpaper',
120-
121121
# The font size ('10pt', '11pt' or '12pt').
122122
#
123123
# 'pointsize': '10pt',
124-
125124
# Additional stuff for the LaTeX preamble.
126125
#
127126
# 'preamble': '',
128-
129127
# Latex figure (float) alignment
130128
#
131129
# 'figure_align': 'htbp',
@@ -135,19 +133,15 @@
135133
# (source start file, target name, title,
136134
# author, documentclass [howto, manual, or own class]).
137135
latex_documents = [
138-
(master_doc, 'python-osc.tex', 'python-osc Documentation',
139-
'attwad', 'manual'),
136+
(master_doc, "python-osc.tex", "python-osc Documentation", "attwad", "manual"),
140137
]
141138

142139

143140
# -- Options for manual page output ------------------------------------------
144141

145142
# One entry per manual page. List of tuples
146143
# (source start file, name, description, authors, manual section).
147-
man_pages = [
148-
(master_doc, 'python-osc', 'python-osc Documentation',
149-
[author], 1)
150-
]
144+
man_pages = [(master_doc, "python-osc", "python-osc Documentation", [author], 1)]
151145

152146

153147
# -- Options for Texinfo output ----------------------------------------------
@@ -156,9 +150,15 @@
156150
# (source start file, target name, title, author,
157151
# dir menu entry, description, category)
158152
texinfo_documents = [
159-
(master_doc, 'python-osc', 'python-osc Documentation',
160-
author, 'python-osc', 'One line description of project.',
161-
'Miscellaneous'),
153+
(
154+
master_doc,
155+
"python-osc",
156+
"python-osc Documentation",
157+
author,
158+
"python-osc",
159+
"One line description of project.",
160+
"Miscellaneous",
161+
),
162162
]
163163

164164

@@ -177,7 +177,7 @@
177177
# epub_uid = ''
178178

179179
# A list of files that should not be packed into the epub file.
180-
epub_exclude_files = ['search.html']
180+
epub_exclude_files = ["search.html"]
181181

182182

183183
# -- Extension configuration -------------------------------------------------

examples/async_server.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ async def loop():
2424

2525
async def init_main():
2626
server = AsyncIOOSCUDPServer((ip, port), dispatcher, asyncio.get_event_loop())
27-
transport, protocol = await server.create_serve_endpoint() # Create datagram endpoint and start serving
27+
transport, protocol = (
28+
await server.create_serve_endpoint()
29+
) # Create datagram endpoint and start serving
2830

2931
await loop() # Enter main loop of program
3032

examples/dispatcher.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ def set_filter(address: str, *args: List[Any]) -> None:
2929
client = SimpleUDPClient("127.0.0.1", 1337)
3030

3131
# Send message and receive exactly one message (blocking)
32-
client.send_message("/filter1", [1., 2.])
32+
client.send_message("/filter1", [1.0, 2.0])
3333
server.handle_request()
3434

35-
client.send_message("/filter8", [6., -2.])
35+
client.send_message("/filter8", [6.0, -2.0])
3636
server.handle_request()

examples/simple_2way.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,21 @@ def print_xy_fader_handler(unused_addr, args, value1, value2):
2525
if __name__ == "__main__":
2626
parser = argparse.ArgumentParser()
2727
parser.add_argument("--serverip", default="127.0.0.1", help="The ip to listen on")
28-
parser.add_argument("--serverport", type=int, default=5005, help="The port the OSC Server is listening on")
29-
parser.add_argument("--clientip", default="127.0.0.1", help="The ip of the OSC server")
30-
parser.add_argument("--clientport", type=int, default=5006, help="The port the OSC Client is listening on")
28+
parser.add_argument(
29+
"--serverport",
30+
type=int,
31+
default=5005,
32+
help="The port the OSC Server is listening on",
33+
)
34+
parser.add_argument(
35+
"--clientip", default="127.0.0.1", help="The ip of the OSC server"
36+
)
37+
parser.add_argument(
38+
"--clientport",
39+
type=int,
40+
default=5006,
41+
help="The port the OSC Client is listening on",
42+
)
3143
args = parser.parse_args()
3244

3345
# listen to addresses and print changes in values
@@ -41,8 +53,7 @@ def print_xy_fader_handler(unused_addr, args, value1, value2):
4153

4254
def start_server(ip, port):
4355
print("Starting Server")
44-
server = osc_server.ThreadingOSCUDPServer(
45-
(ip, port), dispatcher)
56+
server = osc_server.ThreadingOSCUDPServer((ip, port), dispatcher)
4657
print("Serving on {}".format(server.server_address))
4758
thread = threading.Thread(target=server.serve_forever)
4859
thread.start()
@@ -63,7 +74,7 @@ def random_values(client):
6374
client.send_message("/1/fader2", random.random())
6475
client.send_message("/1/fader1", random.random())
6576
client.send_message("/1/xy1", [random.random(), random.random()])
66-
time.sleep(.5)
77+
time.sleep(0.5)
6778

6879

6980
start_server(args.serverip, args.serverport)

examples/simple_client.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
This program sends 10 random values between 0.0 and 1.0 to the /filter address,
44
waiting for 1 seconds between each value.
55
"""
6+
67
import argparse
78
import random
89
import time
@@ -11,10 +12,10 @@
1112

1213
if __name__ == "__main__":
1314
parser = argparse.ArgumentParser()
14-
parser.add_argument("--ip", default="127.0.0.1",
15-
help="The ip of the OSC server")
16-
parser.add_argument("--port", type=int, default=5005,
17-
help="The port the OSC server is listening on")
15+
parser.add_argument("--ip", default="127.0.0.1", help="The ip of the OSC server")
16+
parser.add_argument(
17+
"--port", type=int, default=5005, help="The port the OSC server is listening on"
18+
)
1819
args = parser.parse_args()
1920

2021
client = udp_client.SimpleUDPClient(args.ip, args.port)

examples/simple_server.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
This program listens to several addresses, and prints some information about
44
received packets.
55
"""
6+
67
import argparse
78
import math
89

@@ -23,18 +24,15 @@ def print_compute_handler(unused_addr, args, volume):
2324

2425
if __name__ == "__main__":
2526
parser = argparse.ArgumentParser()
26-
parser.add_argument("--ip",
27-
default="127.0.0.1", help="The ip to listen on")
28-
parser.add_argument("--port",
29-
type=int, default=5005, help="The port to listen on")
27+
parser.add_argument("--ip", default="127.0.0.1", help="The ip to listen on")
28+
parser.add_argument("--port", type=int, default=5005, help="The port to listen on")
3029
args = parser.parse_args()
3130

3231
dispatcher = Dispatcher()
3332
dispatcher.map("/filter", print)
3433
dispatcher.map("/volume", print_volume_handler, "Volume")
3534
dispatcher.map("/logvolume", print_compute_handler, "Log volume", math.log)
3635

37-
server = osc_server.ThreadingOSCUDPServer(
38-
(args.ip, args.port), dispatcher)
36+
server = osc_server.ThreadingOSCUDPServer((args.ip, args.port), dispatcher)
3937
print("Serving on {}".format(server.server_address))
4038
server.serve_forever()

0 commit comments

Comments
 (0)