From 4118ab89de27b29821b3d6b88c76bf28ec87caaf Mon Sep 17 00:00:00 2001 From: gouzil <66515297+gouzil@users.noreply.github.com> Date: Tue, 28 Mar 2023 15:28:04 +0800 Subject: [PATCH] [CodeStyle][B004] hasattr replace callable (#52096) --- pyproject.toml | 2 +- python/paddle/jit/dy2static/convert_call_func.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index cd2feface9de3..63816233fae92 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -89,7 +89,7 @@ select = [ # Bugbear "B002", "B003", - # "B004", + "B004", # "B005", # "B006", # "B007", diff --git a/python/paddle/jit/dy2static/convert_call_func.py b/python/paddle/jit/dy2static/convert_call_func.py index 54734a623410e..75daa4ba13afb 100644 --- a/python/paddle/jit/dy2static/convert_call_func.py +++ b/python/paddle/jit/dy2static/convert_call_func.py @@ -301,7 +301,7 @@ def dyfunc(x): # NOTE: func may have been decorated. converted_call = None - elif hasattr(func, '__class__') and hasattr(func.__class__, '__call__'): + elif hasattr(func, '__class__') and callable(func.__class__): from paddle.nn import Layer if hasattr(func, 'forward') and isinstance(func, Layer):