mirror of
https://github.com/kennethreitz/simplemind.git
synced 2026-06-05 22:50:18 +00:00
handled None case in find_providers
This commit is contained in:
+7
-5
@@ -1,10 +1,12 @@
|
||||
from typing import Union
|
||||
from .providers import providers
|
||||
|
||||
|
||||
def find_provider(provider_name: str):
|
||||
def find_provider(provider_name: Union[str, None]):
|
||||
"""Find a provider by name."""
|
||||
for provider_class in providers:
|
||||
if provider_class.__name__.lower() == provider_name.lower():
|
||||
# Instantiate the provider
|
||||
return provider_class()
|
||||
if provider_name:
|
||||
for provider_class in providers:
|
||||
if provider_class.__name__.lower() == provider_name.lower():
|
||||
# Instantiate the provider
|
||||
return provider_class()
|
||||
raise ValueError(f"Provider {provider_name} not found")
|
||||
|
||||
Reference in New Issue
Block a user