-
-
Notifications
You must be signed in to change notification settings - Fork 27
feat: deprecate string annotations #586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,7 @@ | |
| from __future__ import annotations | ||
|
|
||
| import asyncio | ||
| from typing import Annotated, no_type_check | ||
| from typing import Annotated, Any, no_type_check | ||
|
|
||
| import pytest | ||
|
|
||
|
|
@@ -21,6 +21,19 @@ | |
| from dbus_fast.service import ServiceInterface, dbus_method | ||
|
|
||
|
|
||
| def deprecated_dbus_method(): | ||
| inner_wrapper = dbus_method() | ||
|
|
||
| def outer_wrapper(*args: Any) -> Any: | ||
| with pytest.warns( | ||
| DeprecationWarning, | ||
| match=r"String annotations are deprecated.*Use typing\.Annotated.*instead.", | ||
| ): | ||
| return inner_wrapper(*args) | ||
dlech marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| return outer_wrapper | ||
|
|
||
|
Comment on lines
24
to
35
|
||
|
|
||
| class ExampleInterface(ServiceInterface): | ||
| def __init__(self, name: str) -> None: | ||
| super().__init__(name) | ||
|
|
@@ -32,7 +45,7 @@ def echo(self, what: DBusStr) -> DBusStr: | |
|
|
||
| # This one intentionally keeps string-style annotations for coverage purposes. | ||
| @no_type_check | ||
| @dbus_method() | ||
| @deprecated_dbus_method() | ||
| def echo_multiple(self, what1: "s", what2: "s") -> "ss": # noqa: UP037 | ||
| assert type(self) is ExampleInterface | ||
| return what1, what2 | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.