uranusjr commented on code in PR #38950:
URL: https://github.com/apache/airflow/pull/38950#discussion_r1562051157


##########
airflow/models/dag.py:
##########
@@ -582,7 +582,7 @@ def __init__(
         if start_date and start_date.tzinfo:
             tzinfo = None if start_date.tzinfo else settings.TIMEZONE
             tz = pendulum.instance(start_date, tz=tzinfo).timezone
-        elif "start_date" in self.default_args and 
self.default_args["start_date"]:
+        elif self.default_args.get("start_date"):
             date = self.default_args["start_date"]

Review Comment:
   ```suggestion
           elif date := self.default_args.get("start_date"):
   ```



##########
airflow/providers/google/cloud/hooks/bigquery.py:
##########
@@ -3396,7 +3396,7 @@ def get_records(self, query_results: dict[str, Any], 
as_dict: bool = False) -> l
         :param as_dict: if True returns the result as a list of dictionaries, 
otherwise as list of lists.
         """
         buffer: list[Any] = []
-        if "rows" in query_results and query_results["rows"]:
+        if query_results.get("rows"):
             rows = query_results["rows"]

Review Comment:
   ```suggestion
           if rows := query_results.get("rows"):
   ```



##########
airflow/providers/snowflake/hooks/snowflake_sql_api.py:
##########
@@ -284,9 +284,9 @@ def _process_response(self, status_code, resp):
             return {"status": "error", "message": resp["message"]}
         elif status_code == 200:
             statement_handles = []
-            if "statementHandles" in resp and resp["statementHandles"]:
+            if resp.get("statementHandles"):
                 statement_handles = resp["statementHandles"]
-            elif "statementHandle" in resp and resp["statementHandle"]:
+            elif resp.get("statementHandle"):
                 statement_handles.append(resp["statementHandle"])

Review Comment:
   ```python
   if resp_statement_handles := resp.get("statementHandles"):
       statement_handles = resp_statement_handles
   elif resp_statement_handle := resp.get("statementHandle"):
       statement_handles = [resp_statement_handle]
   else:
       statement_handles = []
   ```



##########
airflow/models/dag.py:
##########
@@ -594,7 +594,7 @@ def __init__(
         self.timezone: Timezone | FixedTimezone = tz or settings.TIMEZONE
 
         # Apply the timezone we settled on to end_date if it wasn't supplied
-        if "end_date" in self.default_args and self.default_args["end_date"]:
+        if self.default_args.get("end_date"):

Review Comment:
   GitHub does not allow me to suggest inline. This can be
   
   ```python
   if isinstance(end_date := self.default_args.get("end_date"), str):
       self.default_args["end_date"] = timezone.parse(end_date, 
timezone=self.timezone)
   ```



##########
airflow/providers/fab/auth_manager/fab_auth_manager.py:
##########
@@ -350,7 +350,7 @@ def get_url_login(self, **kwargs) -> str:
         """Return the login page url."""
         if not self.security_manager.auth_view:
             raise AirflowException("`auth_view` not defined in the security 
manager.")
-        if "next_url" in kwargs and kwargs["next_url"]:
+        if kwargs.get("next_url"):
             return 
url_for(f"{self.security_manager.auth_view.endpoint}.login", 
next=kwargs["next_url"])

Review Comment:
   ```suggestion
           if next_url := kwargs.get("next_url"):
               return 
url_for(f"{self.security_manager.auth_view.endpoint}.login", next=next_url)
   ```



-- 
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]

Reply via email to