kyungjunleeme commented on code in PR #53407:
URL: https://github.com/apache/airflow/pull/53407#discussion_r2212022460
##########
providers/http/src/airflow/providers/http/hooks/http.py:
##########
@@ -172,7 +175,7 @@ def get_conn(
:return: A configured requests.Session object.
"""
session = Session()
- connection = self.get_connection(self.http_conn_id)
+ connection = self.get_connection(self.get_conn_id())
Review Comment:
I plan to gradually refactor providers that currently follow this pattern:
```python
connection = self.get_connection(self.aws_conn_id)
```
```python
connection = self.get_connection(self.get_conn_id())
```
To support this, I've added the following method in BaseHook:
```python
class BaseHook:
def get_conn_id(self) -> str:
if hasattr(self, "conn_name_attr"):
return getattr(self, self.conn_name_attr)
raise NotImplementedError("Subclasses must implement
get_conn_id()")
```
Hardcoding the connection ID attribute directly can become a maintenance
burden, especially as new providers are introduced. Using a consistent, dynamic
approach like get_conn_id() makes the codebase more extensible and reduces the
risk of subtle bugs. I believe this change will make future development and
maintenance smoother.
--
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]