Skip to content

Commit

Permalink
NEW: add the __content__ pseudo-field, resolves #15
Browse files Browse the repository at this point in the history
  • Loading branch information
eigenein committed Mar 31, 2023
1 parent a671020 commit dd58ea3
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 6 deletions.
5 changes: 1 addition & 4 deletions .github/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@ changelog:
- title: 💥 Breaking changes
labels:
- breaking-change
- title: ✨ New features
labels:
- enhancement
- title: ⚡️Improvements
labels:
- improvement
- enhancement
- documentation
- title: 🎨 Other changes
labels:
Expand Down
3 changes: 2 additions & 1 deletion .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions combadge/support/http/aliases.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@
REASON_ALIAS = "__reason__"
Reason: TypeAlias = Annotated[_ReasonT, Field(alias=REASON_ALIAS)]
"""HTTP reason phrase. Alias for the `__reason__` pseudo-field."""

_ContentT = TypeVar("_ContentT", bound=bytes)
CONTENT_ALIAS = "__content__"
Content: TypeAlias = Annotated[_ContentT, Field(alias=CONTENT_ALIAS)]
"""Original response content. Alias for the `__content__` pseudo-field."""
4 changes: 3 additions & 1 deletion combadge/support/httpx/backends/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from combadge.core.interfaces import ProvidesBinder
from combadge.core.typevars import ResponseT
from combadge.support.http.aliases import REASON_ALIAS, STATUS_CODE_ALIAS
from combadge.support.http.aliases import CONTENT_ALIAS, REASON_ALIAS, STATUS_CODE_ALIAS

_ClientT = TypeVar("_ClientT", Client, AsyncClient)

Expand All @@ -18,6 +18,7 @@ class BaseHttpxBackend(ProvidesBinder, Generic[_ClientT]):
# Available response aliases
- [`Content`][combadge.support.http.aliases.Content]: HTTP response content
- [`StatusCode`][combadge.support.http.aliases.StatusCode]: HTTP response status code
- [`Reason`][combadge.support.http.aliases.Reason]: HTTP reason phrase
"""
Expand All @@ -35,6 +36,7 @@ def _parse_response(cls, from_response: Response, to_type: Type[ResponseT]) -> R
{
STATUS_CODE_ALIAS: from_response.status_code,
REASON_ALIAS: from_response.reason_phrase,
CONTENT_ALIAS: from_response.content,
**from_response.json(),
},
)

0 comments on commit dd58ea3

Please sign in to comment.