| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b127121 commit c789ca9
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -24,7 +24,7 @@ | |||
| 24 | 24 | ||
| 25 | 25 | import enum | |
| 26 | 26 | from collections.abc import Callable | |
| 27 | - from typing import TYPE_CHECKING | ||
| 27 | + from typing import TYPE_CHECKING, Any | ||
| 28 | 28 | ||
| 29 | 29 | if TYPE_CHECKING: | |
| 30 | 30 | from .._core import Zeroconf | |
@@ -61,6 +61,7 @@ def fire( | |||
| 61 | 61 | service_type: str, | |
| 62 | 62 | name: str, | |
| 63 | 63 | state_change: ServiceStateChange, | |
| 64 | + **kwargs: Any, | ||
| 64 | 65 | ) -> None: | |
| 65 | 66 | for h in self._handlers[:]: | |
| 66 | 67 | h( | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -303,19 +303,28 @@ def handler( | |||
| 303 | 303 | ] | |
| 304 | 304 | ||
| 305 | 305 | ||
| 306 | - def test_signal_fire_rejects_unknown_kwarg(): | ||
| 307 | - """Signal.fire rejects keyword args outside the contract.""" | ||
| 306 | + def test_signal_fire_discards_unknown_kwarg(): | ||
| 307 | + """Signal.fire accepts extra keyword args and does not forward them.""" | ||
| 308 | 308 | signal = r.Signal() | |
| 309 | - signal.registration_interface.register_handler(lambda **_: None) | ||
| 309 | + captured: list[dict[str, Any]] = [] | ||
| 310 | + signal.registration_interface.register_handler(lambda **kw: captured.append(kw)) | ||
| 310 | 311 | ||
| 311 | - with pytest.raises(TypeError, match="unexpected keyword argument"): | ||
| 312 | - signal.fire( | ||
| 313 | - zeroconf=None, # type: ignore[arg-type] | ||
| 314 | - service_type="_http._tcp.local.", | ||
| 315 | - name="x._http._tcp.local.", | ||
| 316 | - state_change=r.ServiceStateChange.Added, | ||
| 317 | - bogus=1, # type: ignore[call-arg] | ||
| 318 | - ) | ||
| 312 | + signal.fire( | ||
| 313 | + zeroconf=None, # type: ignore[arg-type] | ||
| 314 | + service_type="_http._tcp.local.", | ||
| 315 | + name="x._http._tcp.local.", | ||
| 316 | + state_change=r.ServiceStateChange.Added, | ||
| 317 | + bogus=1, | ||
| 318 | + ) | ||
| 319 | + | ||
| 320 | + assert captured == [ | ||
| 321 | + { | ||
| 322 | + "zeroconf": None, | ||
| 323 | + "service_type": "_http._tcp.local.", | ||
| 324 | + "name": "x._http._tcp.local.", | ||
| 325 | + "state_change": r.ServiceStateChange.Added, | ||
| 326 | + } | ||
| 327 | + ] | ||
| 319 | 328 | ||
| 320 | 329 | ||
| 321 | 330 | def test_signal_fire_rejects_positional_args(): | |
| Back | FazBrowse Home | New Git URL |
0 commit comments