Enhance docstring for find_provider function to include parameters, return type, and exceptions

This commit is contained in:
2024-10-30 17:48:06 -04:00
parent 1405c3bbb0
commit e34f9b106c
+12 -1
View File
@@ -7,7 +7,18 @@ _PROVIDER_NAMES = [provider.NAME.lower() for provider in providers]
def find_provider(provider_name: Union[str, None]):
"""Find a provider by name."""
"""
Find and instantiate a provider by name.
Parameters:
provider_name (Union[str, None]): The name of the provider to find.
Returns:
An instance of the provider class if found.
Raises:
ValueError: If the provider is not found, with a suggestion for the closest match.
"""
if provider_name:
for provider_class in providers:
if provider_class.NAME.lower() == provider_name.lower():