Repository navigation
feat(abstractions): enhance HeadersCollection usability and dict interoperability - #816
Conversation
|
Hi Vincent Biret (@baywet), submitted this PR to resolve #208 by enabling dictionary and HeadersCollection constructor initialization, mapping support in |
|
This pull request has conflicting changes, the author must resolve the conflicts before this pull request can be merged. |
012435e to
4088ad1
Compare
|
Conflicts have been resolved. A maintainer will take a look shortly. |
|
I have resolved the merge conflicts with \main\ and addressed all review feedback:
All local quality gates and checks (\pytest\ 168/168, \mypy\ 0 issues in 48 files, \pylint\ 10.00/10, \yapf, \isort) pass cleanly. Ready for review! |
Vincent Biret (baywet)
left a comment
There was a problem hiding this comment.
Thanks for the contribution!
4088ad1 to
f4c60bd
Compare
|




Description
Fixes #208
This PR addresses the usability improvements requested for
HeadersCollection:HeadersCollectionnow accepts an optional initial headers parameter (Optional[Union[HeadersCollection, Mapping[str, Union[str, Iterable[str]]]]]), allowing direct instantiation from a dictionary or copy-construction from anotherHeadersCollection.add_allDictionary Support:add_allnow accepts either aHeadersCollectionor anyMapping(dict) of header names to values (Union[str, Iterable[str]]), matching the docstring expectation and easing integration across callers.Implements standard Python container magic methods:
__contains__: supports"header" in headers__getitem__: supportsheaders["header"]__setitem__: supportsheaders["header"] = "value"__len__: supportslen(headers)__iter__: supports iterating header keys directlyRelated Issue
Fixes #208
Testing
Added unit tests in
packages/abstractions/tests/test_request_header.py:test_init_with_dicttest_init_with_headers_collectiontest_add_all_with_dicttest_container_methodscc Vincent Biret (@baywet)