(
self, *args: Any, dumps_kwargs: dict[str, Any] | None = None, **kwargs: Any
)
| 25 | attributes: tuple[str, ...] = (*Request.attributes, "dumps_kwargs") |
| 26 | |
| 27 | def __init__( |
| 28 | self, *args: Any, dumps_kwargs: dict[str, Any] | None = None, **kwargs: Any |
| 29 | ) -> None: |
| 30 | dumps_kwargs = copy.deepcopy(dumps_kwargs) if dumps_kwargs is not None else {} |
| 31 | dumps_kwargs.setdefault("sort_keys", True) |
| 32 | self._dumps_kwargs: dict[str, Any] = dumps_kwargs |
| 33 | |
| 34 | body_passed = kwargs.get("body") is not None |
| 35 | data: Any = kwargs.pop("data", None) |
| 36 | data_passed: bool = data is not None |
| 37 | |
| 38 | if body_passed and data_passed: |
| 39 | warnings.warn( |
| 40 | "Both body and data passed. data will be ignored", stacklevel=2 |
| 41 | ) |
| 42 | elif not body_passed and data_passed: |
| 43 | kwargs["body"] = self._dumps(data) |
| 44 | if "method" not in kwargs: |
| 45 | kwargs["method"] = "POST" |
| 46 | |
| 47 | super().__init__(*args, **kwargs) |
| 48 | self.headers.setdefault("Content-Type", "application/json") |
| 49 | self.headers.setdefault( |
| 50 | "Accept", "application/json, text/javascript, */*; q=0.01" |
| 51 | ) |
| 52 | |
| 53 | @property |
| 54 | def dumps_kwargs(self) -> dict[str, Any]: |
nothing calls this directly
no test coverage detected