The Plaid client configuration failed to support case-insensitive dictionary keys, snake_case fallbacks, and keyword-arguments-based initialization. This prevented developers from using common Python patterns (such as passing snake_case keys or direct kwargs) without manual dictionary normalization.
Case-Insensitive Dictionary Normalization
- Implemented a custom
CaseInsensitiveDict subclassing dict that normalizes string keys to lowercase and strips separators (_ and -), mapping keys like client_id, CLIENT_ID, and client-id transparently to clientId.
- Overrode dictionary methods (
__getitem__, __setitem__, __delitem__, __contains__, get, pop, setdefault, update, copy) to maintain standard dictionary semantics under normalization.
- Simplified
get_api_key_with_prefix and auth_settings to leverage CaseInsensitiveDict directly, removing redundant iteration and manual casing fallback blocks.
Constructor Convenience & Property Setters
- Added support for direct keyword arguments (
client_id, secret, plaid_version, environment) to the Configuration constructor, mapping them automatically into api_key and setting host from environment.
- Wrapped
api_key and api_key_prefix with property setters to automatically cast standard dictionaries into CaseInsensitiveDict wrappers.
Code Generator Template Parity
- Replicated identical logic within the template file
templates/python/configuration.mustache to ensure custom behaviors remain resilient across any future OpenAPI generator rebuilds.
Example Usage
import plaid
# Initialization using direct keyword arguments and environment aliases
configuration = plaid.Configuration(
client_id="your-client-id",
secret="your-secret",
plaid_version="2020-09-14",
environment="sandbox"
)
# Case and separator-insensitive key access
assert configuration.api_key['clientId'] == "your-client-id"
assert configuration.api_key['client_id'] == "your-client-id"
# In-place mutations are automatically normalized
configuration.api_key['CLIENT_ID'] = "new-client-id"
assert configuration.get_api_key_with_prefix('clientId') == "new-client-id"
Originally posted by @Copilot in sin-strokes#1
The Plaid client configuration failed to support case-insensitive dictionary keys, snake_case fallbacks, and keyword-arguments-based initialization. This prevented developers from using common Python patterns (such as passing snake_case keys or direct kwargs) without manual dictionary normalization.
Case-Insensitive Dictionary Normalization
CaseInsensitiveDictsubclassingdictthat normalizes string keys to lowercase and strips separators (_and-), mapping keys likeclient_id,CLIENT_ID, andclient-idtransparently toclientId.__getitem__,__setitem__,__delitem__,__contains__,get,pop,setdefault,update,copy) to maintain standard dictionary semantics under normalization.get_api_key_with_prefixandauth_settingsto leverageCaseInsensitiveDictdirectly, removing redundant iteration and manual casing fallback blocks.Constructor Convenience & Property Setters
client_id,secret,plaid_version,environment) to theConfigurationconstructor, mapping them automatically intoapi_keyand settinghostfromenvironment.api_keyandapi_key_prefixwith property setters to automatically cast standard dictionaries intoCaseInsensitiveDictwrappers.Code Generator Template Parity
templates/python/configuration.mustacheto ensure custom behaviors remain resilient across any future OpenAPI generator rebuilds.Example Usage
Originally posted by @Copilot in sin-strokes#1