You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/10/20 19:32:52 UTC

[GitHub] [airflow] ferruzzi commented on a diff in pull request #27040: Allow no extra prefix in yandex hook

ferruzzi commented on code in PR #27040:
URL: https://github.com/apache/airflow/pull/27040#discussion_r1001036980


##########
airflow/providers/yandex/hooks/yandex.py:
##########
@@ -146,9 +146,18 @@ def _get_credentials(self) -> dict[str, Any]:
             return {'token': oauth_token}
 
     def _get_field(self, field_name: str, default: Any = None) -> Any:
-        """Fetches a field from extras, and returns it."""
-        long_f = f'extra__yandexcloud__{field_name}'
-        if hasattr(self, 'extras') and long_f in self.extras:
-            return self.extras[long_f]
-        else:
+        """Get field from extra, first checking short name, then for backcompat we check for prefixed name."""
+        if not hasattr(self, 'extras'):
             return default
+        backcompat_prefix = 'extra__yandexcloud__'
+        if field_name.startswith('extra_'):

Review Comment:
   Non-blocking suggestion, is there a reason to not use startswith(backcompat_prefix)?



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org