Repository: locustio/locust
File: locust/clients.py (Python)

Code before:
            r = LocustResponse()
            r.error = e
            r.status_code = 0  # with this status_code, content returns None
            r.request = Request(method, url).prepare()
            return r

    # These # type: ignore[override] comments below are needed because our overridden version of functions receives
    # more arguments than functions in the base class.
    def get(self, url: str | bytes, **kwargs: Unpack[RESTKwargs]):  # type: ignore[override]
        kwargs.setdefault("allow_redirects", True)
        return self.request("GET", url, **kwargs)  # type: ignore[misc]

    def options(self, url: str | bytes, **kwargs: Unpack[RESTKwargs]):  # type: ignore[override]
        kwargs.setdefault("allow_redirects", True)
        return self.request("OPTIONS", url, **kwargs)  # type: ignore[misc]

    def head(self, url: str | bytes, **kwargs: Unpack[RESTKwargs]):  # type: ignore[override]
        kwargs.setdefault("allow_redirects", False)
        return self.request("HEAD", url, **kwargs)  # type: ignore[misc]

    # These # type: ignore[misc] comments below are needed because data and json parameters are already defined in the
    # RESTKwargs TypedDict. An alternative approach is to define another TypedDict which doesn't contain them.
    def post(self, url: str | bytes, data: Any | None = None, json: Any | None = None, **kwargs: Unpack[RESTKwargs]):  # type: ignore[override, misc]
        return self.request("POST", url, data=data, json=json, **kwargs)  # type: ignore[misc]

    def put(self, url: str | bytes, data: Any | None = None, **kwargs: Unpack[RESTKwargs]):  # type: ignore[override, misc]
        return self.request("PUT", url, data=data, **kwargs)  # type: ignore[misc]

    def patch(self, url: str | bytes, data: Any | None = None, **kwargs: Unpack[RESTKwargs]):  # type: ignore[override, misc]
        return self.request("PATCH", url, data=data, **kwargs)  # type: ignore[misc]

    def delete(self, url: str | bytes, **kwargs: Unpack[RESTKwargs]):  # type: ignore[override]
        return self.request("DELETE", url, **kwargs)  # type: ignore[misc]


class ResponseContextManager(LocustResponse):
    """
    A Response class that also acts as a context manager that provides the ability to manually
    control if an HTTP request should be marked as successful or a failure in Locust's statistics

    This class is a subclass of :py:class:`Response <requests.Response>` with two additional
    methods: :py:meth:`success <locust.clients.ResponseContextManager.success>` and
    :py:meth:`failure <locust.clients.ResponseContextManager.failure>`.
    """

    _manual_result: bool | Exception | None = None
    _entered = False

    def __init__(self, response, request_event, request_meta):
        # copy data from response to this object
        self.__dict__ = response.__dict__

Review comment (suggestion):
```suggestion
    def put(self, url: str | bytes, data: Any | None = None, **kwargs: Unpack[RESTKwargs]) -> (ResponseContextManager | Response | LocustResponse):   # type: ignore[override, misc]
```

Code after:
        except RequestException as e:
            r = LocustResponse()
            r.error = e
            r.status_code = 0  # with this status_code, content returns None
            r.request = Request(method, url).prepare()
            return r

    def get(
        self, url: str | bytes, *, data: Any | None = None, json: Any | None = None, **kwargs: Unpack[RESTKwargs]
    ) -> ResponseContextManager | Response | LocustResponse:
        """Sends a GET request"""
        kwargs.setdefault("allow_redirects", True)
        return self.request("GET", url, data=data, json=json, **kwargs)

    def options(
        self,
        url: str | bytes,
        *,
        data: Any | None = None,
        json: Any | None = None,
        **kwargs: Unpack[RESTKwargs],
    ) -> ResponseContextManager | Response | LocustResponse:
        """Sends a OPTIONS request"""
        kwargs.setdefault("allow_redirects", True)
        return self.request("OPTIONS", url, data=data, json=json, **kwargs)

    def head(
        self,
        url: str | bytes,
        *,
        data: Any | None = None,
        json: Any | None = None,
        **kwargs: Unpack[RESTKwargs],
    ) -> ResponseContextManager | Response | LocustResponse:
        """Sends a HEAD request"""
        kwargs.setdefault("allow_redirects", False)
        return self.request("HEAD", url, data=data, json=json, **kwargs)

    def post(
        self,
        url: str | bytes,
        data: Any | None = None,
        json: Any | None = None,
        **kwargs: Unpack[RESTKwargs],
    ) -> ResponseContextManager | Response | LocustResponse:
        """Sends a POST request"""
        return self.request("POST", url, data=data, json=json, **kwargs)

    def put(
        self,
        url: str | bytes,