feluelle commented on a change in pull request #6574: [AIRFLOW-5924]
Automatically unify bucket name and key in S3Hook
URL: https://github.com/apache/airflow/pull/6574#discussion_r354336573
##########
File path: airflow/providers/amazon/aws/hooks/s3.py
##########
@@ -36,24 +37,48 @@
def provide_bucket_name(func):
"""
Function decorator that provides a bucket name taken from the connection
- in case no bucket name has been passed to the function and, if available,
also no key has been passed.
+ in case no bucket name has been passed to the function.
"""
@wraps(func)
def wrapper(*args, **kwargs):
- func_params = func.__code__.co_varnames
+ bound_args = signature(func).bind(*args, **kwargs)
- def has_arg(name):
- name_in_args = name in func_params and func_params.index(name) <
len(args)
- name_in_kwargs = name in kwargs
- return name_in_args or name_in_kwargs
-
- if not has_arg('bucket_name') and not (has_arg('key') or
has_arg('wildcard_key')):
+ if 'bucket_name' not in bound_args.arguments:
Review comment:
Oh there is an issue I did not test. Using `in` doesn't work at all for
searching in a list of tuple matching the specific param. It searches for the
complete tuple. 🤦♂
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services