| 934 | |
| 935 | @final |
| 936 | class FinalRequestOptions(pydantic.BaseModel): |
| 937 | method: str |
| 938 | url: str |
| 939 | params: Query = {} |
| 940 | headers: Union[Headers, NotGiven] = NotGiven() |
| 941 | max_retries: Union[int, NotGiven] = NotGiven() |
| 942 | timeout: Union[float, Timeout, None, NotGiven] = NotGiven() |
| 943 | files: Union[HttpxRequestFiles, None] = None |
| 944 | idempotency_key: Union[str, None] = None |
| 945 | post_parser: Union[Callable[[Any], Any], NotGiven] = NotGiven() |
| 946 | follow_redirects: Union[bool, None] = None |
| 947 | |
| 948 | content: Union[bytes, bytearray, IO[bytes], Iterable[bytes], AsyncIterable[bytes], None] = None |
| 949 | # It should be noted that we cannot use `json` here as that would override |
| 950 | # a BaseModel method in an incompatible fashion. |
| 951 | json_data: Union[Body, None] = None |
| 952 | extra_json: Union[AnyMapping, None] = None |
| 953 | |
| 954 | if PYDANTIC_V1: |
| 955 | |
| 956 | class Config(pydantic.BaseConfig): # pyright: ignore[reportDeprecated] |
| 957 | arbitrary_types_allowed: bool = True |
| 958 | else: |
| 959 | model_config: ClassVar[ConfigDict] = ConfigDict(arbitrary_types_allowed=True) |
| 960 | |
| 961 | def get_max_retries(self, max_retries: int) -> int: |
| 962 | if isinstance(self.max_retries, NotGiven): |
| 963 | return max_retries |
| 964 | return self.max_retries |
| 965 | |
| 966 | def _strip_raw_response_header(self) -> None: |
| 967 | if not is_given(self.headers): |
| 968 | return |
| 969 | |
| 970 | if self.headers.get(RAW_RESPONSE_HEADER): |
| 971 | self.headers = {**self.headers} |
| 972 | self.headers.pop(RAW_RESPONSE_HEADER) |
| 973 | |
| 974 | # override the `construct` method so that we can run custom transformations. |
| 975 | # this is necessary as we don't want to do any actual runtime type checking |
| 976 | # (which means we can't use validators) but we do want to ensure that `NotGiven` |
| 977 | # values are not present |
| 978 | # |
| 979 | # type ignore required because we're adding explicit types to `**values` |
| 980 | @classmethod |
| 981 | def construct( # type: ignore |
| 982 | cls, |
| 983 | _fields_set: set[str] | None = None, |
| 984 | **values: Unpack[FinalRequestOptionsInput], |
| 985 | ) -> FinalRequestOptions: |
| 986 | kwargs: dict[str, Any] = { |
| 987 | # we unconditionally call `strip_not_given` on any value |
| 988 | # as it will just ignore any non-mapping types |
| 989 | key: strip_not_given(value) |
| 990 | for key, value in values.items() |
| 991 | } |
| 992 | if PYDANTIC_V1: |
| 993 | return cast(FinalRequestOptions, super().construct(_fields_set, **kwargs)) # pyright: ignore[reportDeprecated] |