Skip to content
This repository is currently being migrated. It's locked while the migration is in progress.

Replaced isfunction & ismethod with isroutine #707

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
8 changes: 1 addition & 7 deletions baseplate/clients/thrift.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,9 @@ def _enumerate_service_methods(client: Any) -> Iterator[str]:
"""Return an iterable of service methods from a generated Iface class."""
ifaces_found = 0

# python3 drops the concept of unbound methods, so they're just plain
# functions and we have to account for that here. see:
# https://stackoverflow.com/questions/17019949/why-is-there-a-difference-between-inspect-ismethod-and-inspect-isfunction-from-p # noqa: E501
def predicate(x: Any) -> bool:
return inspect.isfunction(x) or inspect.ismethod(x)

for base_cls in inspect.getmro(client):
if base_cls.__name__ == "Iface":
for name, _ in inspect.getmembers(base_cls, predicate):
for name, _ in inspect.getmembers(base_cls, inspect.isroutine):
yield name
ifaces_found += 1

Expand Down