Skip to content

Commit

Permalink
Reformat the code using Black
Browse files Browse the repository at this point in the history
We could use some style consistency in the project and Black looks like
the best tool for the job.

Two flake8 errors are being silenced from now on:

* E203 whitespace before :
* W503 line break before binary operator

Both are to satisfy Black-formatted code (and W503 is somemwhat against
the latest PEP8 recommendations regarding line breaks and binary
operators in new code).
  • Loading branch information
jstasiak committed May 15, 2019
1 parent d4e06bc commit beb596c
Show file tree
Hide file tree
Showing 8 changed files with 391 additions and 375 deletions.
2 changes: 1 addition & 1 deletion examples/browser.py
Expand Up @@ -12,7 +12,7 @@


def on_service_state_change(
zeroconf: Zeroconf, service_type: str, name: str, state_change: ServiceStateChange,
zeroconf: Zeroconf, service_type: str, name: str, state_change: ServiceStateChange
) -> None:
print("Service %s of type %s state changed: %s" % (name, service_type, state_change))

Expand Down
14 changes: 10 additions & 4 deletions examples/registration.py
Expand Up @@ -17,10 +17,16 @@

desc = {'path': '/~paulsm/'}

info = ServiceInfo("_http._tcp.local.",
"Paul's Test Web Site._http._tcp.local.",
socket.inet_aton("127.0.0.1"), 80, 0, 0,
desc, "ash-2.local.")
info = ServiceInfo(
"_http._tcp.local.",
"Paul's Test Web Site._http._tcp.local.",
socket.inet_aton("127.0.0.1"),
80,
0,
0,
desc,
"ash-2.local.",
)

zeroconf = Zeroconf()
print("Registration of a service, press Ctrl-C to exit...")
Expand Down
15 changes: 10 additions & 5 deletions examples/self_test.py
Expand Up @@ -18,15 +18,20 @@
r = Zeroconf()
print("1. Testing registration of a service...")
desc = {'version': '0.10', 'a': 'test value', 'b': 'another value'}
info = ServiceInfo("_http._tcp.local.",
"My Service Name._http._tcp.local.",
socket.inet_aton("127.0.0.1"), 1234, 0, 0, desc)
info = ServiceInfo(
"_http._tcp.local.",
"My Service Name._http._tcp.local.",
socket.inet_aton("127.0.0.1"),
1234,
0,
0,
desc,
)
print(" Registering service...")
r.register_service(info)
print(" Registration done.")
print("2. Testing query of service information...")
print(" Getting ZOE service: %s" % (
r.get_service_info("_http._tcp.local.", "ZOE._http._tcp.local.")))
print(" Getting ZOE service: %s" % (r.get_service_info("_http._tcp.local.", "ZOE._http._tcp.local.")))
print(" Query done.")
print("3. Testing query of own service...")
queried_info = r.get_service_info("_http._tcp.local.", "My Service Name._http._tcp.local.")
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
@@ -0,0 +1,4 @@
[tool.black]
line-length = 110
target_version = ['py35', 'py36', 'py37']
skip_string_normalization = true
1 change: 1 addition & 0 deletions setup.cfg
Expand Up @@ -2,6 +2,7 @@
show-source = 1
application-import-names=zeroconf
max-line-length=110
ignore=E203,W503

[mypy]
ignore_missing_imports = true
Expand Down
16 changes: 5 additions & 11 deletions setup.py
Expand Up @@ -11,14 +11,14 @@
version = (
[l for l in open(join(PROJECT_ROOT, 'zeroconf.py')) if '__version__' in l][0]
.split('=')[-1]
.strip().strip('\'"')
.strip()
.strip('\'"')
)

setup(
name='zeroconf',
version=version,
description='Pure Python Multicast DNS Service Discovery Library '
'(Bonjour/Avahi compatible)',
description='Pure Python Multicast DNS Service Discovery Library ' '(Bonjour/Avahi compatible)',
long_description=readme,
author='Paul Scott-Murphy, William McBrine, Jakub Stasiak',
url='https://github.com/jstasiak/python-zeroconf',
Expand All @@ -41,12 +41,6 @@
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
],
keywords=[
'Bonjour', 'Avahi', 'Zeroconf', 'Multicast DNS', 'Service Discovery',
'mDNS',
],
install_requires=[
'ifaddr',
'typing;python_version<"3.5"'
],
keywords=['Bonjour', 'Avahi', 'Zeroconf', 'Multicast DNS', 'Service Discovery', 'mDNS'],
install_requires=['ifaddr', 'typing;python_version<"3.5"'],
)

0 comments on commit beb596c

Please sign in to comment.