uranusjr commented on code in PR #33234:
URL: https://github.com/apache/airflow/pull/33234#discussion_r1288183871
##########
airflow/providers/http/hooks/http.py:
##########
@@ -340,31 +340,18 @@ async def run(
if headers:
_headers.update(headers)
- if self.base_url and not self.base_url.endswith("/") and endpoint and
not endpoint.startswith("/"):
- url = self.base_url + "/" + endpoint
- else:
- url = (self.base_url or "") + (endpoint or "")
+ url = "/".join([(self.base_url or "").rstrip("/"), (endpoint or
"").lstrip("/")])
async with aiohttp.ClientSession() as session:
- if self.method == "GET":
- request_func = session.get
- elif self.method == "POST":
- request_func = session.post
- elif self.method == "PATCH":
- request_func = session.patch
- elif self.method == "HEAD":
- request_func = session.head
- elif self.method == "PUT":
- request_func = session.put
- elif self.method == "DELETE":
- request_func = session.delete
- elif self.method == "OPTIONS":
- request_func = session.options
+ if self.method in ("GET", "POST", "PATCH", "HEAD", "PUT",
"DELETE", "OPTIONS"):
+ request_func = getattr(session, self.method.lower())
Review Comment:
Not particularly fond of this particular rewrite tbh.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]