From bdc90dc3c029384876f9b6db82cf3d76f453c359 Mon Sep 17 00:00:00 2001 From: Kaxil Naik Date: Fri, 14 Jan 2022 12:16:25 +0530 Subject: [PATCH] Fix MyPy issues in AWS Sensors (#20863) Part of https://github.com/apache/airflow/issues/19891 Before: ``` root@12e9fcfb4678:/opt/airflow# mypy --namespace-packages airflow/providers/amazon/aws/sensors airflow/providers/amazon/aws/sensors/s3.py:182: error: Incompatible types in assignment (expression has type "function", variable has type "Callable[..., bool]") [assignment] check_fn: Callable[..., bool] = self.check_fn_user if self.check_fn_user is not None else self.check_fn ^ Found 1 error in 1 file (checked 33 source files) ``` After: ``` root@12e9fcfb4678:/opt/airflow# mypy --namespace-packages airflow/providers/amazon/aws/sensors Success: no issues found in 33 source files ``` GitOrigin-RevId: b15027410b4a985c15b1d7b2b2a0eedf2173f416 --- airflow/providers/amazon/aws/sensors/s3.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/airflow/providers/amazon/aws/sensors/s3.py b/airflow/providers/amazon/aws/sensors/s3.py index 884318bfda2..b31b9cdceba 100644 --- a/airflow/providers/amazon/aws/sensors/s3.py +++ b/airflow/providers/amazon/aws/sensors/s3.py @@ -179,8 +179,9 @@ def poke(self, context: 'Context'): s3_objects = self.get_files(s3_hook=self.get_hook()) if not s3_objects: return False - check_fn = self.check_fn if self.check_fn_user is None else self.check_fn_user - return check_fn(s3_objects) + if self.check_fn_user is not None: + return self.check_fn_user(s3_objects) + return self.check_fn(s3_objects) def get_files(self, s3_hook: S3Hook, delimiter: Optional[str] = '/') -> List: """Gets a list of files in the bucket"""