Skip to content

Commit 300eec0

Browse files
authored
Merge branch 'master' into improve_outgoing
2 parents 9e06114 + d20d8c1 commit 300eec0

20 files changed

Lines changed: 117 additions & 130 deletions

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ repos:
3939
- id: pyupgrade
4040
args: [--py38-plus]
4141
- repo: https://github.com/astral-sh/ruff-pre-commit
42-
rev: v0.8.6
42+
rev: v0.9.1
4343
hooks:
4444
- id: ruff
4545
args: [--fix, --exit-non-zero-on-fix]

examples/async_apple_scanner.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ def async_on_service_state_change(
5555
async def _async_show_service_info(zeroconf: Zeroconf, service_type: str, name: str) -> None:
5656
info = AsyncServiceInfo(service_type, name)
5757
await info.async_request(zeroconf, 3000, question_type=DNSQuestionType.QU)
58-
print("Info from zeroconf.get_service_info: %r" % (info))
58+
print(f"Info from zeroconf.get_service_info: {info!r}")
5959
if info:
60-
addresses = ["%s:%d" % (addr, cast(int, info.port)) for addr in info.parsed_addresses()]
61-
print(" Name: %s" % name)
62-
print(" Addresses: %s" % ", ".join(addresses))
63-
print(" Weight: %d, priority: %d" % (info.weight, info.priority))
60+
addresses = [f"{addr}:{cast(int, info.port)}" for addr in info.parsed_addresses()]
61+
print(f" Name: {name}")
62+
print(f" Addresses: {', '.join(addresses)}")
63+
print(f" Weight: {info.weight}, priority: {info.priority}")
6464
print(f" Server: {info.server}")
6565
if info.properties:
6666
print(" Properties are:")
@@ -82,7 +82,7 @@ def __init__(self, args: Any) -> None:
8282
async def async_run(self) -> None:
8383
self.aiozc = AsyncZeroconf(ip_version=ip_version)
8484
await self.aiozc.zeroconf.async_wait_for_start()
85-
print("\nBrowsing %s service(s), press Ctrl-C to exit...\n" % ALL_SERVICES)
85+
print(f"\nBrowsing {ALL_SERVICES} service(s), press Ctrl-C to exit...\n")
8686
kwargs = {
8787
"handlers": [async_on_service_state_change],
8888
"question_type": DNSQuestionType.QU,

examples/async_browser.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ def async_on_service_state_change(
3535
async def async_display_service_info(zeroconf: Zeroconf, service_type: str, name: str) -> None:
3636
info = AsyncServiceInfo(service_type, name)
3737
await info.async_request(zeroconf, 3000)
38-
print("Info from zeroconf.get_service_info: %r" % (info))
38+
print(f"Info from zeroconf.get_service_info: {info!r}")
3939
if info:
40-
addresses = ["%s:%d" % (addr, cast(int, info.port)) for addr in info.parsed_scoped_addresses()]
41-
print(" Name: %s" % name)
42-
print(" Addresses: %s" % ", ".join(addresses))
43-
print(" Weight: %d, priority: %d" % (info.weight, info.priority))
40+
addresses = [f"{addr}:{cast(int, info.port)}" for addr in info.parsed_scoped_addresses()]
41+
print(f" Name: {name}")
42+
print(f" Addresses: {', '.join(addresses)}")
43+
print(f" Weight: {info.weight}, priority: {info.priority}")
4444
print(f" Server: {info.server}")
4545
if info.properties:
4646
print(" Properties are:")
@@ -68,7 +68,7 @@ async def async_run(self) -> None:
6868
await AsyncZeroconfServiceTypes.async_find(aiozc=self.aiozc, ip_version=ip_version)
6969
)
7070

71-
print("\nBrowsing %s service(s), press Ctrl-C to exit...\n" % services)
71+
print(f"\nBrowsing {services} service(s), press Ctrl-C to exit...\n")
7272
self.aiobrowser = AsyncServiceBrowser(
7373
self.aiozc.zeroconf, services, handlers=[async_on_service_state_change]
7474
)

examples/async_service_info_request.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ async def async_watch_services(aiozc: AsyncZeroconf) -> None:
3030
tasks = [info.async_request(aiozc.zeroconf, 3000) for info in infos]
3131
await asyncio.gather(*tasks)
3232
for info in infos:
33-
print("Info for %s" % (info.name))
33+
print(f"Info for {info.name}")
3434
if info:
35-
addresses = ["%s:%d" % (addr, cast(int, info.port)) for addr in info.parsed_addresses()]
36-
print(" Addresses: %s" % ", ".join(addresses))
37-
print(" Weight: %d, priority: %d" % (info.weight, info.priority))
35+
addresses = [f"{addr}:{cast(int, info.port)}" for addr in info.parsed_addresses()]
36+
print(f" Addresses: {', '.join(addresses)}")
37+
print(f" Weight: {info.weight}, priority: {info.priority}")
3838
print(f" Server: {info.server}")
3939
if info.properties:
4040
print(" Properties are:")

examples/browser.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ def on_service_state_change(
2626

2727
if state_change is ServiceStateChange.Added:
2828
info = zeroconf.get_service_info(service_type, name)
29-
print("Info from zeroconf.get_service_info: %r" % (info))
29+
print(f"Info from zeroconf.get_service_info: {info!r}")
3030

3131
if info:
32-
addresses = ["%s:%d" % (addr, cast(int, info.port)) for addr in info.parsed_scoped_addresses()]
33-
print(" Addresses: %s" % ", ".join(addresses))
34-
print(" Weight: %d, priority: %d" % (info.weight, info.priority))
32+
addresses = [f"{addr}:{cast(int, info.port)}" for addr in info.parsed_scoped_addresses()]
33+
print(f" Addresses: {', '.join(addresses)}")
34+
print(f" Weight: {info.weight}, priority: {info.priority}")
3535
print(f" Server: {info.server}")
3636
if info.properties:
3737
print(" Properties are:")
@@ -75,7 +75,7 @@ def on_service_state_change(
7575
if args.find:
7676
services = list(ZeroconfServiceTypes.find(zc=zeroconf))
7777

78-
print("\nBrowsing %d service(s), press Ctrl-C to exit...\n" % len(services))
78+
print(f"\nBrowsing {len(services)} service(s), press Ctrl-C to exit...\n")
7979
browser = ServiceBrowser(zeroconf, services, handlers=[on_service_state_change])
8080

8181
try:

examples/self_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
r.register_service(info)
3535
print(" Registration done.")
3636
print("2. Testing query of service information...")
37-
print(" Getting ZOE service: %s" % (r.get_service_info("_http._tcp.local.", "ZOE._http._tcp.local.")))
37+
print(f" Getting ZOE service: {r.get_service_info('_http._tcp.local.', 'ZOE._http._tcp.local.')}")
3838
print(" Query done.")
3939
print("3. Testing query of own service...")
4040
queried_info = r.get_service_info("_http._tcp.local.", "My Service Name._http._tcp.local.")

poetry.lock

Lines changed: 23 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ ifaddr = ">=0.1.7"
7676
[tool.poetry.group.dev.dependencies]
7777
pytest = ">=7.2,<9.0"
7878
pytest-cov = ">=4,<6"
79-
pytest-asyncio = ">=0.20.3,<0.25.0"
79+
pytest-asyncio = ">=0.20.3,<0.26.0"
8080
cython = "^3.0.5"
8181
setuptools = ">=65.6.3,<76.0.0"
8282
pytest-timeout = "^2.1.0"
@@ -90,7 +90,6 @@ line-length = 110
9090
ignore = [
9191
"S101", # use of assert
9292
"S104", # S104 Possible binding to all interfaces
93-
"UP031", # UP031 use f-strings -- too many to fix right now
9493
]
9594
select = [
9695
"B", # flake8-bugbear

requirements-dev.txt

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/zeroconf/_dns.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def entry_to_string(self, hdr: str, other: Optional[Union[bytes, str]]) -> str:
102102
self.get_class_(self.class_),
103103
"-unique" if self.unique else "",
104104
self.name,
105-
"=%s" % cast(Any, other) if other is not None else "",
105+
f"={cast(Any, other)}" if other is not None else "",
106106
)
107107

108108

0 commit comments

Comments
 (0)