requests icon indicating copy to clipboard operation
requests copied to clipboard

Add union operator support to CaseInsensitiveDict (PEP 584)

Open Cubicpath opened this issue 3 years ago • 0 comments
trafficstars

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'}

Cubicpath avatar Jun 18 '22 10:06 Cubicpath