Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def subscription_from_attribute(attribute):
try:
if isinstance(attribute, Subscription):
subscription = attribute
elif issubclass(attribute, Subscription):
subscription = attribute()
else:
return None
except TypeError:
# If attribute is not a class, TypeError is raised when testing issubclass
return None
return subscription
def decorator(func):
return Subscription(
func=func, topic=topic, prefix=prefix, suffix=suffix, filter_by=filter_by,
)
def subscription_from_attribute(attribute):
try:
if isinstance(attribute, Subscription):
subscription = attribute
elif issubclass(attribute, Subscription):
subscription = attribute()
else:
return None
except TypeError:
# If attribute is not a class, TypeError is raised when testing issubclass
return None
return subscription