Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def auth_or_string(value):
if value is None:
return value
elif isinstance(value, Auth):
return value
elif isinstance(value, str) and value.count(":") == 1:
username, password = value.split(":")
return BasicAuth(username, password)
else:
raise TypeError()