Skip to content

Conversation

@Cubicpath
Copy link

Adds support for the | and |= operators for CaseInsensitiveDict.

This copies the functionality of dict from PEP 584. Even though this PEP was implemented in 3.9, the functionality implemented to CaseInsensitiveDict still works in all currently supported versions (3.7+).

This also brings a level of consistency with other Mapping types, i.e. OrderedDict, MappingProxyType, ChainMap, WeakKeyDictionary, and more have this as supported behavior.

The code itself is a slightly modified version of the reference implementation.

Example usage:

session = Session()
session.headers |= {'Accept', 'application/json'}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant