ferruzzi commented on code in PR #27823:
URL: https://github.com/apache/airflow/pull/27823#discussion_r1028636765
##########
airflow/providers/amazon/aws/hooks/base_aws.py:
##########
@@ -405,9 +411,68 @@ def __init__(
self.resource_type = resource_type
self._region_name = region_name
- self._config = config
+ self._config = config or botocore.config.Config()
self._verify = verify
+ @classmethod
+ def _get_provider_version(cls) -> str:
+ """Checks the Providers Manager for the package version."""
+ manager = ProvidersManager()
+ provider_name = manager.hooks[cls.conn_type].package_name # type:
ignore[union-attr]
Review Comment:
`manager.hooks` is an `Optional[HookInfo]`, so MyPy will complain that
```
error: Item "None" of "Optional[HookInfo]" has no attribute "package_name"
[union-attr]
```
I could do something like this instead. It feels more confusing, but it
does catch the (unlikely??) exception case where ProvidersManager breaks?
```
@classmethod
def _get_provider_version(cls) -> str:
"""Checks the Providers Manager for the package version."""
manager = ProvidersManager()
hook = manager.hooks[cls.conn_type]
if not hook:
return "Unknown"
provider = manager.providers[hook.provider_name]
return provider.version
```
--
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]