Skip to content

Commit b7b9c5c

Browse files
committed
Add workaround for internal override assignment typing
Apparently there is confusion between `MethodType` and `FunctionType` in the older versions of mypy. Add an ignore comment to have it be compatible between mypy versions.
1 parent 9adcb23 commit b7b9c5c

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/sdbus/dbus_proxy_async_interface_base.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
from collections.abc import Callable
2323
from copy import copy
2424
from itertools import chain
25-
from types import MethodType
2625
from typing import TYPE_CHECKING, Any, cast
2726
from warnings import warn
2827
from weakref import WeakKeyDictionary, WeakValueDictionary
@@ -73,21 +72,23 @@ def _process_dbus_method_override(
7372
mro_dbus_elements: dict[str, DbusMemberAsync],
7473
) -> DbusMethodAsync:
7574
try:
76-
original_method = mro_dbus_elements[override_attr_name]
75+
original_dbus_method = mro_dbus_elements[override_attr_name]
7776
except KeyError:
7877
raise ValueError(
7978
f"No D-Bus method {override_attr_name!r} found "
8079
f"to override."
8180
)
8281

83-
if not isinstance(original_method, DbusMethodAsync):
82+
if not isinstance(original_dbus_method, DbusMethodAsync):
8483
raise TypeError(
85-
f"Expected {DbusMethodAsync!r} got {original_method!r} "
84+
f"Expected {DbusMethodAsync!r} got {original_dbus_method!r} "
8685
f"under name {override_attr_name!r}"
8786
)
8887

89-
new_method = copy(original_method)
90-
new_method.original_method = cast(MethodType, override.override_method)
88+
new_method = copy(original_dbus_method)
89+
new_method.original_method = (
90+
override.override_method # type: ignore[assignment]
91+
)
9192
return new_method
9293

9394
@staticmethod

0 commit comments

Comments
 (0)