Skip to content
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

Replaced isfunction & ismethod with isroutine #707

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
11 changes: 3 additions & 8 deletions baseplate/clients/thrift.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,16 +159,11 @@ 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):
yield name
for name in base_cls.__dict__:
if callable(getattr(base_cls, name)):
yield name
ifaces_found += 1

assert ifaces_found > 0, "class is not a thrift client; it has no Iface"
Expand Down