requests
requests copied to clipboard
Add union operator support to CaseInsensitiveDict (PEP 584)
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'}