Skip to content

Commit d3bfe4e

Browse files
committed
Drop python 3.6 support
1 parent b0e8c8a commit d3bfe4e

14 files changed

Lines changed: 53 additions & 76 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
strategy:
1515
matrix:
1616
os: [ubuntu-latest, macos-latest, windows-latest]
17-
python-version: [3.6, 3.7, 3.8, 3.9, "3.10", "pypy-3.6", "pypy-3.7"]
17+
python-version: [3.7, 3.8, 3.9, "3.10", "pypy-3.7"]
1818
include:
1919
- os: ubuntu-latest
2020
venvcmd: . env/bin/activate

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ Compared to some other Zeroconf/Bonjour/Avahi Python packages, python-zeroconf:
4444
Python compatibility
4545
--------------------
4646

47-
* CPython 3.6+
48-
* PyPy3 7.2+
47+
* CPython 3.7+
48+
* PyPy3.7 7.3+
4949

5050
Versioning
5151
----------

tests/services/test_browser.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python
2-
# -*- coding: utf-8 -*-
32

43

54
""" Unit tests for zeroconf._services.browser. """
@@ -682,7 +681,7 @@ def on_service_state_change(zeroconf, service_type, state_change, name):
682681

683682
info_service = ServiceInfo(
684683
type_,
685-
'%s.%s' % (name, type_),
684+
f'{name}.{type_}',
686685
80,
687686
0,
688687
0,
@@ -902,7 +901,7 @@ def test_group_ptr_queries_with_known_answers():
902901
now = current_time_millis()
903902
for i in range(120):
904903
name = f"_hap{i}._tcp._local."
905-
questions_with_known_answers[DNSQuestion(name, const._TYPE_PTR, const._CLASS_IN)] = set(
904+
questions_with_known_answers[DNSQuestion(name, const._TYPE_PTR, const._CLASS_IN)] = {
906905
DNSPointer(
907906
name,
908907
const._TYPE_PTR,
@@ -911,7 +910,7 @@ def test_group_ptr_queries_with_known_answers():
911910
f"zoo{counter}.{name}",
912911
)
913912
for counter in range(i)
914-
)
913+
}
915914
outs = _services_browser._group_ptr_queries_with_known_answers(now, True, questions_with_known_answers)
916915
for out in outs:
917916
packets = out.packets()
@@ -937,7 +936,7 @@ async def test_generate_service_query_suppress_duplicate_questions():
937936
10000,
938937
f'known-to-other.{name}',
939938
)
940-
other_known_answers = set([answer])
939+
other_known_answers = {answer}
941940
zc.question_history.add_question_at_time(question, now, other_known_answers)
942941
assert zc.question_history.suppresses(question, now, other_known_answers)
943942

@@ -976,16 +975,16 @@ async def test_generate_service_query_suppress_duplicate_questions():
976975
@pytest.mark.asyncio
977976
async def test_query_scheduler():
978977
delay = const._BROWSER_TIME
979-
types_ = set(["_hap._tcp.local.", "_http._tcp.local."])
978+
types_ = {"_hap._tcp.local.", "_http._tcp.local."}
980979
query_scheduler = _services_browser.QueryScheduler(types_, delay, (0, 0))
981980

982981
now = current_time_millis()
983982
query_scheduler.start(now)
984983

985984
# Test query interval is increasing
986985
assert query_scheduler.millis_to_wait(now - 1) == 1
987-
assert query_scheduler.millis_to_wait(now) is 0
988-
assert query_scheduler.millis_to_wait(now + 1) is 0
986+
assert query_scheduler.millis_to_wait(now) == 0
987+
assert query_scheduler.millis_to_wait(now + 1) == 0
989988

990989
assert set(query_scheduler.process_ready_types(now)) == types_
991990
assert set(query_scheduler.process_ready_types(now)) == set()
@@ -1013,8 +1012,8 @@ async def test_query_scheduler():
10131012
assert set(query_scheduler.process_ready_types(now + delay * 15)) == set()
10141013

10151014
# Test if we reschedule 1 second later... and its ready for processing
1016-
assert set(query_scheduler.process_ready_types(now + delay * 16)) == set(["_hap._tcp.local."])
1015+
assert set(query_scheduler.process_ready_types(now + delay * 16)) == {"_hap._tcp.local."}
10171016
assert query_scheduler.millis_to_wait(now) == delay * 31
10181017
assert set(query_scheduler.process_ready_types(now + delay * 20)) == set()
10191018

1020-
assert set(query_scheduler.process_ready_types(now + delay * 31)) == set(["_http._tcp.local."])
1019+
assert set(query_scheduler.process_ready_types(now + delay * 31)) == {"_http._tcp.local."}

tests/services/test_info.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python
2-
# -*- coding: utf-8 -*-
32

43

54
""" Unit tests for zeroconf._services.info. """
@@ -574,7 +573,7 @@ async def test_multiple_a_addresses():
574573
# New kwarg way
575574
info = ServiceInfo(type_, registration_name, 80, 0, 0, desc, host)
576575
info.load_from_cache(aiozc.zeroconf)
577-
assert set(info.addresses) == set([b'a', b'b'])
576+
assert set(info.addresses) == {b'a', b'b'}
578577
await aiozc.async_close()
579578

580579

@@ -585,7 +584,7 @@ def test_filter_address_by_type_from_service_info():
585584
desc = {'path': '/~paulsm/'}
586585
type_ = "_homeassistant._tcp.local."
587586
name = "MyTestHome"
588-
registration_name = "%s.%s" % (name, type_)
587+
registration_name = f"{name}.{type_}"
589588
ipv4 = socket.inet_aton("10.0.1.2")
590589
ipv6 = socket.inet_pton(socket.AF_INET6, "2001:db8::1")
591590
info = ServiceInfo(type_, registration_name, 80, 0, 0, desc, "ash-2.local.", addresses=[ipv4, ipv6])
@@ -605,7 +604,7 @@ def test_changing_name_updates_serviceinfo_key():
605604
name = "MyTestHome"
606605
info_service = ServiceInfo(
607606
type_,
608-
'%s.%s' % (name, type_),
607+
f'{name}.{type_}',
609608
80,
610609
0,
611610
0,
@@ -627,7 +626,7 @@ def test_serviceinfo_address_updates():
627626
with pytest.raises(TypeError):
628627
info_service = ServiceInfo(
629628
type_,
630-
'%s.%s' % (name, type_),
629+
f'{name}.{type_}',
631630
80,
632631
0,
633632
0,
@@ -639,7 +638,7 @@ def test_serviceinfo_address_updates():
639638

640639
info_service = ServiceInfo(
641640
type_,
642-
'%s.%s' % (name, type_),
641+
f'{name}.{type_}',
643642
80,
644643
0,
645644
0,
@@ -658,12 +657,12 @@ def test_serviceinfo_accepts_bytes_or_string_dict():
658657
addresses = [socket.inet_aton("10.0.1.2")]
659658
server_name = "ash-2.local."
660659
info_service = ServiceInfo(
661-
type_, '%s.%s' % (name, type_), 80, 0, 0, {b'path': b'/~paulsm/'}, server_name, addresses=addresses
660+
type_, f'{name}.{type_}', 80, 0, 0, {b'path': b'/~paulsm/'}, server_name, addresses=addresses
662661
)
663662
assert info_service.dns_text().text == b'\x0epath=/~paulsm/'
664663
info_service = ServiceInfo(
665664
type_,
666-
'%s.%s' % (name, type_),
665+
f'{name}.{type_}',
667666
80,
668667
0,
669668
0,
@@ -674,7 +673,7 @@ def test_serviceinfo_accepts_bytes_or_string_dict():
674673
assert info_service.dns_text().text == b'\x0epath=/~paulsm/'
675674
info_service = ServiceInfo(
676675
type_,
677-
'%s.%s' % (name, type_),
676+
f'{name}.{type_}',
678677
80,
679678
0,
680679
0,
@@ -685,7 +684,7 @@ def test_serviceinfo_accepts_bytes_or_string_dict():
685684
assert info_service.dns_text().text == b'\x0epath=/~paulsm/'
686685
info_service = ServiceInfo(
687686
type_,
688-
'%s.%s' % (name, type_),
687+
f'{name}.{type_}',
689688
80,
690689
0,
691690
0,

tests/services/test_registry.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python
2-
# -*- coding: utf-8 -*-
32

43

54
"""Unit tests for zeroconf._services.registry."""
@@ -15,7 +14,7 @@ class TestServiceRegistry(unittest.TestCase):
1514
def test_only_register_once(self):
1615
type_ = "_test-srvc-type._tcp.local."
1716
name = "xxxyyy"
18-
registration_name = "%s.%s" % (name, type_)
17+
registration_name = f"{name}.{type_}"
1918

2019
desc = {'path': '/~paulsm/'}
2120
info = ServiceInfo(
@@ -32,8 +31,8 @@ def test_register_same_server(self):
3231
type_ = "_test-srvc-type._tcp.local."
3332
name = "xxxyyy"
3433
name2 = "xxxyyy2"
35-
registration_name = "%s.%s" % (name, type_)
36-
registration_name2 = "%s.%s" % (name2, type_)
34+
registration_name = f"{name}.{type_}"
35+
registration_name2 = f"{name2}.{type_}"
3736

3837
desc = {'path': '/~paulsm/'}
3938
info = ServiceInfo(
@@ -61,7 +60,7 @@ def test_unregister_multiple_times(self):
6160
"""
6261
type_ = "_test-srvc-type._tcp.local."
6362
name = "xxxyyy"
64-
registration_name = "%s.%s" % (name, type_)
63+
registration_name = f"{name}.{type_}"
6564

6665
desc = {'path': '/~paulsm/'}
6766
info = ServiceInfo(
@@ -77,7 +76,7 @@ def test_unregister_multiple_times(self):
7776
def test_lookups(self):
7877
type_ = "_test-srvc-type._tcp.local."
7978
name = "xxxyyy"
80-
registration_name = "%s.%s" % (name, type_)
79+
registration_name = f"{name}.{type_}"
8180

8281
desc = {'path': '/~paulsm/'}
8382
info = ServiceInfo(
@@ -96,7 +95,7 @@ def test_lookups(self):
9695
def test_lookups_upper_case_by_lower_case(self):
9796
type_ = "_test-SRVC-type._tcp.local."
9897
name = "Xxxyyy"
99-
registration_name = "%s.%s" % (name, type_)
98+
registration_name = f"{name}.{type_}"
10099

101100
desc = {'path': '/~paulsm/'}
102101
info = ServiceInfo(
@@ -115,7 +114,7 @@ def test_lookups_upper_case_by_lower_case(self):
115114
def test_lookups_lower_case_by_upper_case(self):
116115
type_ = "_test-srvc-type._tcp.local."
117116
name = "xxxyyy"
118-
registration_name = "%s.%s" % (name, type_)
117+
registration_name = f"{name}.{type_}"
119118

120119
desc = {'path': '/~paulsm/'}
121120
info = ServiceInfo(

tests/services/test_types.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python
2-
# -*- coding: utf-8 -*-
32

43

54
"""Unit tests for zeroconf._services.types."""
@@ -36,7 +35,7 @@ def test_integration_with_listener(self):
3635

3736
type_ = "_test-listen-type._tcp.local."
3837
name = "xxxyyy"
39-
registration_name = "%s.%s" % (name, type_)
38+
registration_name = f"{name}.{type_}"
4039

4140
zeroconf_registrar = Zeroconf(interfaces=['127.0.0.1'])
4241
desc = {'path': '/~paulsm/'}
@@ -72,7 +71,7 @@ def test_integration_with_listener_v6_records(self):
7271

7372
type_ = "_test-listenv6rec-type._tcp.local."
7473
name = "xxxyyy"
75-
registration_name = "%s.%s" % (name, type_)
74+
registration_name = f"{name}.{type_}"
7675
addr = "2606:2800:220:1:248:1893:25c8:1946" # example.com
7776

7877
zeroconf_registrar = Zeroconf(interfaces=['127.0.0.1'])
@@ -109,7 +108,7 @@ def test_integration_with_listener_ipv6(self):
109108

110109
type_ = "_test-listenv6ip-type._tcp.local."
111110
name = "xxxyyy"
112-
registration_name = "%s.%s" % (name, type_)
111+
registration_name = f"{name}.{type_}"
113112
addr = "2606:2800:220:1:248:1893:25c8:1946" # example.com
114113

115114
zeroconf_registrar = Zeroconf(ip_version=r.IPVersion.V6Only)
@@ -145,8 +144,8 @@ def test_integration_with_subtype_and_listener(self):
145144
type_ = "_listen._tcp.local."
146145
name = "xxxyyy"
147146
# Note: discovery returns only DNS-SD type not subtype
148-
discovery_type = "%s.%s" % (subtype_, type_)
149-
registration_name = "%s.%s" % (name, type_)
147+
discovery_type = f"{subtype_}.{type_}"
148+
registration_name = f"{name}.{type_}"
150149

151150
zeroconf_registrar = Zeroconf(interfaces=['127.0.0.1'])
152151
desc = {'path': '/~paulsm/'}

tests/utils/test_asyncio.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python
2-
# -*- coding: utf-8 -*-
32

43

54
"""Unit tests for zeroconf._utils.asyncio."""

tests/utils/test_name.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python
2-
# -*- coding: utf-8 -*-
32

43

54
"""Unit tests for zeroconf._utils.name."""

tests/utils/test_net.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python
2-
# -*- coding: utf-8 -*-
32

43

54
"""Unit tests for zeroconf._utils.net."""
@@ -86,7 +85,7 @@ def test_normalize_interface_choice_errors():
8685
def test_add_multicast_member_socket_errors(errno, expected_result):
8786
"""Test we handle socket errors when adding multicast members."""
8887
if errno:
89-
setsockopt_mock = unittest.mock.Mock(side_effect=OSError(errno, "Error: {}".format(errno)))
88+
setsockopt_mock = unittest.mock.Mock(side_effect=OSError(errno, f"Error: {errno}"))
9089
else:
9190
setsockopt_mock = unittest.mock.Mock()
9291
fileno_mock = unittest.mock.PropertyMock(return_value=10)

zeroconf/_services/browser.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
SignalRegistrationInterface,
3939
)
4040
from .._updates import RecordUpdate, RecordUpdateListener
41-
from .._utils.asyncio import get_best_available_queue
4241
from .._utils.name import service_type_name
4342
from .._utils.time import current_time_millis, millis_to_seconds
4443
from ..const import (
@@ -145,11 +144,11 @@ def generate_service_query(
145144
for type_ in types_:
146145
question = DNSQuestion(type_, _TYPE_PTR, _CLASS_IN)
147146
question.unicast = qu_question
148-
known_answers = set(
147+
known_answers = {
149148
cast(DNSPointer, record)
150149
for record in zc.cache.get_all_by_details(type_, _TYPE_PTR, _CLASS_IN)
151150
if not record.is_stale(now)
152-
)
151+
}
153152
if not qu_question and zc.question_history.suppresses(
154153
question, now, cast(Set[DNSRecord], known_answers)
155154
):
@@ -293,7 +292,7 @@ def __init__(
293292
self._pending_handlers: OrderedDict[Tuple[str, str], ServiceStateChange] = OrderedDict()
294293
self._service_state_changed = Signal()
295294
self.query_scheduler = QueryScheduler(self.types, delay, _FIRST_QUERY_DELAY_RANDOM_INTERVAL)
296-
self.queue: Optional[queue.Queue] = None
295+
self.queue: Optional[queue.SimpleQueue] = None
297296
self.done = False
298297
self._first_request: bool = True
299298
self._next_send_timer: Optional[asyncio.TimerHandle] = None
@@ -511,11 +510,11 @@ def __init__(
511510
# Add the queue before the listener is installed in _setup
512511
# to ensure that events run in the dedicated thread and do
513512
# not block the event loop
514-
self.queue = get_best_available_queue()
513+
self.queue = queue.SimpleQueue()
515514
self.daemon = True
516515
self.start()
517516
zc.loop.call_soon_threadsafe(self._async_start)
518-
self.name = "zeroconf-ServiceBrowser-%s-%s" % (
517+
self.name = "zeroconf-ServiceBrowser-{}-{}".format(
519518
'-'.join([type_[:-7] for type_ in self.types]),
520519
getattr(self, 'native_id', self.ident),
521520
)

0 commit comments

Comments
 (0)